Click here to Skip to main content
15,907,687 members
Please Sign up or sign in to vote.
1.67/5 (5 votes)
See more:
Is this pinguin a bird ? :)

[a picture of the pinguin, containing also advertising, has been removed]


Please
any idea to prevent the usage of its fly() function ? :)

class bird
{
...
public:
...
  virtual void fly();
};

class pinguin : public bird
{
...
};
Posted
Updated 5-Mar-10 2:02am
v6

class pinguin : bird
{
   new private void fly() { }
}


The fly method will be private, i.e. not accessible from any implementation.
 
Share this answer
 
Hmm... :)

bird theBird;
pinguin thePinguin;
 
covey theCovey;
theCovey.add(theBird);
theCovey.add(thePinguin);
 
bird* pBird = theCovey.GetFirstBird();
while (pBird) {
  pBird->fly();
  // now is here a pinguin, a bird as well... :)
  pBird = theCovey.GetNextBird();
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900