Well, how do I make a function of class return the class it was called for?
For some reason I have a feeling "return self;" won't work...
Well, how do I make a function of class return the class it was called for?
For some reason I have a feeling "return self;" won't work...
If you are returning a pointer to the instance, then return this, else if just an object return *this
"only two things are infinite, the universe and human stupidity, and im not sure about the former." - albert einstein
you can return a different instance of a class easily. i have a graph class with a function which returns a graph object, different from the graph that was calling it. Is that what you mean?
For member functions of a class, use return *this;
For free functions, like operators, return whichever argument is valid for the next statement.