⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 animal.cpp

📁 这是一个dos版的应用程序
💻 CPP
字号:
// ***************************************************************
//  Animal   version:  1.0   ? date: 12/02/2006
//  -------------------------------------------------------------
//  Animal.cpp
//  -------------------------------------------------------------
//  Copyright (C) 2006 - All Rights Reserved
// ***************************************************************
// 
// ***************************************************************

#include "Animal.h"
#include <string.h>
//----------------------------------------------------------------
istream& operator >>(istream &stream,Animal& obj){
		cout<<"输入宠物的颜色:";
		stream>>obj.s_Color;
		cout<<"输入宠物的体重:";
		stream>>obj.n_Weight;
		cout<<"输入宠物喜爱的食物:";
		stream>>obj.s_Food;
		return stream;	
}
//----------------------------------------------------------------
Animal::Animal(){
	s_Type=new char[12];
	s_Color=new char[12];
	s_Food=new char[20];
	n_Weight=0;
	strcpy(s_Type,"     ");
	strcpy(s_Food,"     ");
	strcpy(s_Type,"    ");
//	cout<<"Animal constructor"<<endl;
}
//----------------------------------------------------------------

void Animal::ChangeType(char* t){
	strcpy(s_Type,t);
}
// ---------------------------------------------------------------

void Animal::ChangeColor(char* c){
	strcpy(s_Color,c);
}
//----------------------------------------------------------------

void Animal::ChangeFood(char* f){
	strcpy(s_Food,f);
}
//----------------------------------------------------------------

void Animal::ChangeWeight(int w){
	n_Weight=w;
}

//----------------------------------------------------------------
Animal::~Animal(){	
	delete[] s_Food;
	delete[] s_Color;	
	delete[] s_Type;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -