Results 1 to 6 of 6

Thread: Just to get some things straight

  1. #1

    Thread Starter
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134

    Just to get some things straight

    On my way to learning C++, I have bought SAMS Teach Yourself (21 Days) book... and what excellent value it was. I'm on day 9 now, just finished pointers... One thing's unclear. If I got it right, these two mean the same thing?
    Code:
    (*pPointer).PublicVar
    Code:
    pPointer->PublicVar
    If so, then I'm on to day nine
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  2. #2
    Frenzied Member Zaei's Avatar
    Join Date
    Jul 2002
    Location
    My own little world...
    Posts
    1,710
    Yes, they are the same thing. Using the arrow is just easier to type =).

    Z.

  3. #3

    Thread Starter
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    I heard that I finally understand pointers (yippie)
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  4. #4
    Frenzied Member
    Join Date
    Jul 2002
    Posts
    1,370
    The -> operator means a pointer to a member. Go for day 9

  5. #5
    Member
    Join Date
    Jun 2003
    Posts
    56
    say i had a structure with values in it like name, health

    eg
    struct person
    {
    char[10] name;
    int health;
    }

    person Me

    Me->name = "johnny"

    would that apply aswell?

  6. #6
    Fanatic Member McCain's Avatar
    Join Date
    Jan 2002
    Location
    Sweden/Denmark
    Posts
    802
    Yes, you can use the -> operator on structs as well, but you can't do what you try to do. You can't assign things to a character array with the = operator, you need to use the strcpy() function...
    Never argue with fools, they will only drag you down to their level, and beat you with experience.

    Q: How do you tell an experienced hacker from a novice?
    A: The latter thinks there's 1000 bytes in a kilobyte, while the former is sure there's 1024 meters in a kilometer

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width