📄 animal.cpp
字号:
#include "Animal.h"
#include <string>
#include <iostream>
using namespace std;
//构造函数
Animal::Animal(char *n,char *k,unsigned int kf,char *c,unsigned int ki,char *f)
{
Name=new char[strlen(n)+1];
strcpy(Name,n);
Kind=new char[strlen(k)+1];
strcpy(Kind,k);
Color=new char[strlen(c)+1];
strcpy(Color,c);
kilo=ki;
KindFlag=kf;
Food=new char[strlen(f)+1];
strcpy(Food,f);
}
//析构函数
Animal::~Animal()
{
delete[] Name;
delete[] Kind;
delete[] Color;
delete[] Food;
}
//显示信息
void Animal::Print(void)
{
cout.width(8);
cout<<Name;
cout.width(8);
cout<<Kind;
cout.width(8);
cout<<Color;
cout.width(8);
cout<<kilo;
cout.width(8);
cout<<Food<<endl;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -