Is he just declaring two functions to use function overloading for the constructor?
As said i am new to c++ so i appreciate any help. The actual code is part of the c4 game engine. I'm a 3d artist attempting to bridge the gap to programming, so you may see me here quite a bit!
Thanks for the reply. After seeing that my last two questions were actually in the documentation i checked there first this time, but didn't find an answer (unless i missed it):
Controller *Replicate(void) const;
What is that line doing? Assuming Controller is a class, to me it looks like it is a constant function named Replicate that takes no arguments and returns type Controller (or more so returns an object of the controller class). But i am not sure what the * is doing there. I know the * can be for multiplication, a deference operator, or simply for declaring a pointer, but i am not sure if the code is doing any of those things.
Furthermore the functions definition syntax is a little confusing too:
1 2 3 4
Controller *SpinController::Replicate(void) const
{
return (new SpinController(*this));
}
But i'm assuming that will make sense once i understand the function declaration/prototype above. I'm mainly used to programming in php in a procedural manner so i'm still wrapping my head around a lot of this class syntax.
Controller *SpinController::Replicate(void) const
{
return (new SpinController(*this));
}
Member function returning a pointer to controller which take no arguments and doesn't modify the caller object
allocate a new SpinController copying the current one ( new here is calling the copy constructor ) and return the pointer returned from new