void myClass<temp_Type>::myFunction(myClass<temp_Type>* &firstClass, myClass<temp_Type>* secondClass)


myFunction(*this, &secondClass);

I think I am fundamentally challenged on the "this" qualifier. I want to pass a pointer to the current object(ie the object I am calling the function from), but am stuck trying to pass the "this". Are there any other methods to go about something such as this?

9 Years
Discussion Span
Last Post by Narue

this is a pointer, *this dereferences the pointer. So if you want to pass a pointer just don't use the asterisk. myFunction(this, &copyClass); That doesn't mean it will solve your problem, but that's how to pass pointers.

That looks like a recursive function call, I doubt you even need to pass this pointer because the compiler will do that anyway.


Since I need to change the actual object itself, I would need to do something along the lines of &this

Unsure of if its legal or not, going to try it now. Thanks for the quick replies.


Nah, &this is illegal, compiler fusses at me :D Time for a new approach ::cracks fingers::


The special pointer this has type Class*const (not Class*) so you can't pass this as an argument to myFunction.

It seems the myfunction member has a slightly unusual signature with the 1st parameter of type "a reference to a pointer to myClass<temp_Type>". Can you explain what do you want to do with the 1st parameter of this member function?


this is certainly a bugger. I ended up having to re-route what I was trying to accomplish. I do appreciate the help.


>I ended up having to re-route what I was trying to accomplish.
What were you trying to accomplish? The way I'm reading your problem, you're confused about what this is. A pointer to the current object is always available from a non-static member function; you don't have to pass it explicitly.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.