game-programming-patterns
game-programming-patterns copied to clipboard
Subclass sandbox: Sandbox method access modifier
In web version of your book activate method is sometimes protected
class Superpower
{
protected:
SoundPlayer& getSoundPlayer()
{
return soundPlayer_;
}
// Sandbox method and other operations... <---- this comment is in protected scope
private:
SoundPlayer soundPlayer_;
};
and sometimes it's public
class Superpower
{
public:
Superpower(ParticleSystem* particles)
: particles_(particles)
{}
// Sandbox method and other operations... <---- this comment is in public scope
private:
ParticleSystem* particles_;
};
I'm also trying to figure, who calls the activate method? Our superhero creates SkyLaunch object and calls activate(), or is activate() called in SkyLaunch contructor?