2014-14週目-プロジェクト1-動物はこう呼ばれています

2705 ワード

/*
*            :
*Copyright(c)2014,           
*All rights reserved.
*    :
*  :   
*    :2014  05 26 
*   :v1.0
*             :
*    :  
*    :     
*    : 
*    :
*    :
*/
#include <iostream>
#include<string>
using namespace std;



class Animal
{
public:
    virtual void cry()
    {
        cout<<"      ,      ?"<<endl;
    }
};
class Mouse:public Animal
{
public:
    Mouse(string n,char s):name(n),sex(s) {}




    virtual void cry()
    {
        cout<< "  "<<name<<",   ";
        if (sex=='m')cout<<" ";
        cout<<" ";
        cout<<"  ,     :   !" <<endl;

    }
private:
    string name;
    char sex;


};
class Cat:public Animal
{
public :
    Cat(string n):name(n) {}
    virtual void cry()
    {
        cout<<"  "<<name<<",    ,      :   !"<<endl;

    }

private:
    string name ;


};
class Dog:public Animal
{

public :
    Dog(string n):name(n) {}
    virtual void cry()
    {


        cout<<"  "<<name <<",    ,     :   !"<<endl;
    }

private:
    string name ;

};
class Giraffe:public Animal
{
public :
    Giraffe(string n,char s):name(n),sex(s) {}
    virtual void cry()
    {


        cout<<"  "<<name<<", ";
        if (sex=='m')cout<<" ";
        cout<<" ";
        cout<<"   ,      ,      !"<<endl;

    }
private:
    string name ;
    char sex;
};

int main( )
{
    Animal *p;
    p = new Animal();
    p->cry();
    Mouse m1("Jerry",'m');
    p=&m1;
    p->cry();
    Mouse m2("Jemmy",'f');
    p=&m2;
    p->cry();
    Cat c1("Tom");
    p=&c1;
    p->cry();
    Dog d1("Droopy");
    p=&d1;
    p->cry();
    Giraffe g1("Gill",'m');
    p=&g1;
    p->cry();
    return 0;
}

私は***と言って、1人の女子学生で、私の叫び声は:あははは!