hi everybody,
What's the use of .* operator in c++?
please explain this concept with an example.
hi everybody,
What's the use of .* operator in c++?
please explain this concept with an example.
These are two different operators.
The asterisk dereferences a pointer. (Gets-to the data pointed-to by the pointer.)
The period/dot-operator accesses either a data member of a structure, or a data-member or member-function of an object.
So, together they would access either member-data or a member function via a pointer.
Code:X = DougDbug.*pAge; //X = Doug's age Y = avil_beloved.*pAge; // Y = Avil's age
Last edited by DougDbug; 10-18-2004 at 01:22 PM.
nitpick.* is a syntax error, *grib.pAge de-references what member pointer pAge references. This is why you have -> if grib was a pointer to a structure then you would need the ugly syntax *(*pGrib).pAge
No.Originally Posted by DougDbug
Here's a page I found explaining this operator and the ->* operator thoroughly.
http://linuxquality.sunsite.dk/articles/memberpointers/
Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling
Sang-drax is correct
Pointer to member provides only an offset into an object of the member's class at which that member can be found.
Can't be overloaded as well.
Mr. C.
Mr. C: Author and Instructor
that is a pointer which references to contents of another variables address for instance
int *p
p=&a;
which means that p references the contents of the variable a's address.