キリン類の動物類への継承(public継承)
1759 ワード
01./*
02.* :
03.* Copyright (c) 2011,
04.* All rights reserved.
05.* :test.cpp
06.* :
07.* :2014 05 17
08.* :v1.0
09.* :
10.* :
11.* :
12.* :
13.* :
14.* :
15.*/
#include <iostream>
using namespace std;
class Animal //
{
public:
Animal() {}
void eat(){
cout << "eat
";
}
protected:
void play()
{
cout << "play
";
}
private:
void drink()
{
cout << "drink
";
}
};
class Giraffe: public Animal //
{
public:
Giraffe() {}
void StrechNeck()
{
cout << "Strech neck
";
}
private:
void take()
{
eat(); // , ,
//drink(); // _ , , ______________
play(); // _ , , ______________
}
};
int main()
{
Giraffe gir; //
gir.eat(); // , ,
//gir.play(); // , , _______________
//gir.drink(); // ,Giraffe Animal _______________
//gir.take(); // ,Giraffe _______________
gir.StrechNeck(); // __ ,Giraffe _____________
Animal ani;
ani.eat(); // _ ,Animal ______________
//ani.play(); // _ ,Animal ______________
//ani.drink(); // _ ,Animal ______________
//ani.take(); // , ( )
//ani.StrechNeck(); // , ( ) _______________
return 0;
}