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
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
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.
yup.
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
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
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
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
-> 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
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