Hi,
Could anyone explain to me why this works? I can't figure out
the wonky const syntax!
class Surface
{
...
protected:
SDL_Surface* data;
static SDL_Surface* const&
get_others_data(const Surface& arg);
...
};
SDL_Surface* const&
Surface::get_others_data(const Surface& arg)
{
return arg.data;
}
As you can see, it returns a reference to a pointer, so the
pointer itself can be manipulated/reset (why? If you can to
know, I can tell you later.)
When I declared it as 'const SDL_Surface*&', it threw a funny
error, though (below). I can't understand the change in syntax
that was needed.
src/System/Surface.cc: In static member function `static const
SDL_Surface*&
Shotgun_Robot::Surface::get_others_data(const
Shotgun_Robot::Surface&)':
src/System/Surface.cc:275: error: invalid initialization of
reference of type '
const SDL_Surface*&' from expression of type 'SDL_Surface* const'
Thanks,
Asfand Yar
--
http://www.it-is-truth.org/