game-programming-patterns icon indicating copy to clipboard operation
game-programming-patterns copied to clipboard

Subclass sandbox: Sandbox method access modifier

Open PrzemyslawNowaczyk opened this issue 9 years ago • 0 comments

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?

PrzemyslawNowaczyk avatar Sep 15 '16 11:09 PrzemyslawNowaczyk