1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
|
// Implementation file: apple.cc
struct Apple::AppleStruct
{
AppleStruct( int m, int r, int g, int b ) : mass(m), red(r), green(g), blue(b) {}
int mass ;
int red, green, blue ;
int GetMass() const noexcept { return mass ; }
int Eat( int biteSize, int bites = 1 ) ;
// ...
};
int Apple::AppleStruct::Eat( int biteSize, int bites )
{
// TODO:
return 0 ;
}
Apple::Apple( int mass, int red, int green, int blue )
: implementation( new AppleStruct(mass,red,green,blue) ) {}
Apple::Apple( const Apple& that )
: implementation( new AppleStruct( *that.implementation.get() ) ) {}
Apple::Apple( Apple&& that ) noexcept
: implementation( std::move(that.implementation) ) {}
// Apple copy asssignment
// Apple move assignment
int Apple::GetMass() const noexcept { return implementation->GetMass() ; }
int Apple::Eat( int biteSize, int bites )
{ return implementation->Eat(biteSize,bites) ; }
// etc
|