hey guys.. am learning c++
just started.. am not able to implement member dereferencing operators.. i know there basic definations and rules but...its like.. a clear picture is still not coming to my mind..as in how to make use of them.. please explain with examples..

Recommended Answers

All 7 Replies

There is no such concept as "dereferencing and operator". Operators are like <, >, <=, /, +, etc. You probably mean dereferencing a pointer.

int n = 123;
int* p = &n;
*p = 0; // dereferencing a pointer

He perhaps, meant that he wants to customize the uranary * operator ( the dereferencing operator) for is custom class.

I don't know why would you like to do that but here is what I got:
Overload dereference operator like this:

T& operator*() const //this will return some value of type T
{
return *m_ptr;//return some value of type T
}

Src: http://www.velocityreviews.com/forums/t450268-overloading-global-dereference-operator.html

He perhaps, meant that he wants to customize the uranary * operator ( the dereferencing operator) for is custom class.

He mentions that he just started learning C++:

hey guys.. am learning c++
just started..

I think that's usually not one of the first topics you'll learn (if you're learning C++), but it could be he meant that though I find it strange he would :) ...

"implementing the dereferencing operator" means overloading it for your class.
I though agree, that the OP may not referring to operator overloading.
Anyways, in that case, the Dragon has already replied.

There is no such concept as "dereferencing and operator". Operators are like <, >, <=, /, +, etc. You probably mean dereferencing a pointer.

int n = 123;
int* p = &n;
*p = 0; // dereferencing a pointer

It's interesting that there is a page in the new C++ Standard Draft where operator*() named dereferencing operator. However as usually this operator called indirection operator in C++ Std docs.

okay i think i should clarify my query..
am writing down the definations from my source of learning-
operator function
::* To declare a pointer to a member of a class
.* To access a member using object name and a
pointer to that member
->* To access a member using a pointer to the object
and a pointer to that member


okay..now can u please give me some sample programs using above member dereferencing operators..i'll be highly obliged..
come on guys.. help me out!!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.