Thread: Usage

  1. #1
    Registered User whistlenm1's Avatar
    Join Date
    Jan 2002
    Posts
    124

    Usage

    Curious how would I use the following C++ operators:

    .*
    ->*

    using C sence I can derive a possible meaning, but that does not mean I am right, thanks in advance
    Man's mind once streched by a new idea, never regains its original dimensions
    - Oliver Wendell Holmes

    In other words, if you teach your cat to bark (output) and eat dog food (input) that doesn't make him a dog. It would have to chase cars, chew bones, and have puppies before I'd call it Rover ;-)
    - WaltP

  2. #2
    Registered User subdene's Avatar
    Join Date
    Jan 2002
    Posts
    367
    isn't the '.' used to access member functions and data types in scope, but '->' is used to access members through a pointer.
    Be a leader and not a follower.

  3. #3
    Registered User
    Join Date
    May 2002
    Posts
    317
    yup.

  4. #4
    Registered User
    Join Date
    Apr 2002
    Posts
    362
    Subdene,

    Bingo!

    (One of those little issues that seems to confuse folks, but you're exactly right. Good job.)

    "When the only tool you own is a hammer, every problem begins to resemble a nail." Abraham Maslow

  5. #5
    Registered User subdene's Avatar
    Join Date
    Jan 2002
    Posts
    367
    cool.
    Be a leader and not a follower.

  6. #6
    Registered User whistlenm1's Avatar
    Join Date
    Jan 2002
    Posts
    124
    No guys, forgive me for not being more specific but I mean (.*) and (->*). I came across these operators in the book C++ programmers notebook but did not find any examples.
    Man's mind once streched by a new idea, never regains its original dimensions
    - Oliver Wendell Holmes

    In other words, if you teach your cat to bark (output) and eat dog food (input) that doesn't make him a dog. It would have to chase cars, chew bones, and have puppies before I'd call it Rover ;-)
    - WaltP

  7. #7
    Registered User foniks munkee's Avatar
    Join Date
    Nov 2001
    Posts
    343
    Could you provide some context, cos to me the previous posters answered the question correctly.

    Do you mean used in the following fashion?

    foo.bar or foo->bar

  8. #8
    Registered User whistlenm1's Avatar
    Join Date
    Jan 2002
    Posts
    124
    If possible, I mean

    foo.*bar or foo->*bar.

    page 61 in C++ Programmers Handbook gives a listing of operators and at precedence level 4 they give the dot and struct pointer operator both in conjunction with the *(indirection operator) as follows:

    .*
    ->*

    or buys some chance a misprint
    Man's mind once streched by a new idea, never regains its original dimensions
    - Oliver Wendell Holmes

    In other words, if you teach your cat to bark (output) and eat dog food (input) that doesn't make him a dog. It would have to chase cars, chew bones, and have puppies before I'd call it Rover ;-)
    - WaltP

  9. #9
    Registered User
    Join Date
    Jun 2002
    Posts
    106
    -> is used for pointers
    . is used for objects
    C++ Makes you Feel Better

    "Gravity connot be held reponsible for people falling in love"--Albert Einstein

  10. #10
    Registered User
    Join Date
    Apr 2002
    Posts
    362
    Nope. It's not a misprint at all. (Where the heck are the "big guns" when I need 'em? )

    In C++, class members can be referred to via an indirect method involving the use of "pointers to members" of the class. That's what your notation is concerned with.

    foo->bar(); is a direct call to the 'bar' member function of a class, for example.

    (foo->*bar) (); is a call, through a "pointer to member", i.e. an indirect call to a class member function via a pointer.

    'foo.*bar' binds member 'bar' to class object 'foo'. (Note that 'foo', in this example, is a class object name and not the same 'foo' mentioned above.)

    I'd really like to see someone with more experience/knowledge dive in here, but, absent any such help, suffice it to say that both "operators" serve to indirectly access class members as opposed to directly accessing them with the more familiar operators.

    "When the only tool you own is a hammer, every problem begins to resemble a nail." Abraham Maslow

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Reduce CPU usage
    By patrick22 in forum Windows Programming
    Replies: 9
    Last Post: 07-10-2009, 02:13 PM
  2. Net cpu usage of pthreads?!
    By mynickmynick in forum C++ Programming
    Replies: 15
    Last Post: 09-26-2008, 07:59 AM
  3. Memory usage and memory leaks
    By vsanandan in forum C Programming
    Replies: 1
    Last Post: 05-03-2008, 05:45 AM
  4. Calculating CPU Usage
    By vitaliy in forum Linux Programming
    Replies: 3
    Last Post: 08-21-2005, 09:38 AM
  5. Win2K Limiting CPU Usage?
    By drdroid in forum Tech Board
    Replies: 4
    Last Post: 03-31-2004, 02:08 PM