- 北大“面向对象程序设计”上机试题(含答案)
- 发布日期时间:2007-3-6 来源:不详 点击数: 作者:佚名
cout<<“My weight is ”<<weight<<endl;
cout<<“My favorite food is ”<<food<<endl;
return ;
}
int Dog::number()
{
return Dognum;
}
std::istream & operator>>(std::istream &is ,Dog &dog)
{
cout<<“the dog's name is”;
is>>dog.name;
cout<<endl<<“ the dog's color is ”;
is>>dog.color;
cout<<endl<<“the dog's weight is ”;
is>>dog.weight;
cout<<endl<<“the dog's fovarite food is:”;
is>>dog.food;
return is;
}
void Dog::deleteme()
{
Dognum——;
}
Dog::~Dog()
{}
int Snake::Snakenum=0;
Snake::Snake()
{
type=2;
name=new char [20];
color=new char [20];
food=new char [20];
Snakenum++;
}
void Snake::showme()
{
cout<<endl<<“I am a Snake”<<endl;
cout<<“My name is ”<<name<<endl;
cout<<“ My color is ”<<color<<endl;
cout<<“My weight is ”<<weight<<endl;
cout<<“My favorite food is ”<<food<<endl;
return ;
}
int Snake::number()
{
return Snakenum;
}
std::istream & operator>>(std::istream &is ,Snake &snake)
{
cout<<“the snake's name is”;
is>>snake.name;
cout<<endl<<“ the snake's color is ”;
is>>snake.color;
cout<<endl<<“the snake's weight is ”;
is>>snake.weight;
cout<<endl<<“the snake's fovarite food is:”;
is>>snake.food;
return is;
}
void Snake::deleteme()
{
Snakenum——;
}
Snake::~Snake()
{}
Shelves::Shelves()
{
for(int i=0;i<12;i++)
{
shelves[i]=NULL;
}
}
int Shelves::add(int n,Animal * animal)
{
int successful=1;
if(shelves[n]!=NULL)
{
cout<<“the ”<<n<<“ the shelve is full”<<endl;
successful=0;
return successful;
}
shelves[n]=animal;
cout<<“ successful!”<<endl;
return successful;
}
void Shelves::query(int n)
{
if(shelves[n]==NULL)
{
cout<<“the ”<<n<<“ the shelve is empty!”<<endl;
return ;
}
shelves[n]->showme();
return ;
}
void Shelves::Delete(int n)
{
上一页 [1] [2] [3] [4] [5] [6] [7] [8] [9] 下一页
文章转载请注明来源于:汕头自考网
|
|



