#include<iostream>
using namespace std;
class Dog{
public:
Dog(int initialAge=0,int initialWeight=5);
~Dog();
int getAge(){return age;
}
void setAge(int age){
this->age=age;
}
int getWeight(){
return weight;
}
void setWeight(int weight){
this->weight=weight;
}
private:
int age,weight;
};
Dog::Dog(int initialAge,int initialWeight){
age=initialAge;
weight=initialWeight;
}
Dog::~Dog()
{
}
int main(){
Dog Jake(2,10);
cout<<"Jake is a Dog who is";
cout<<Jake.getAge()<<"years old and "<<Jake.getWeight()<<"pounds weight"<<endl;
Jake.setAge(7);
Jake.setWeight(20);
cout<<"Now Jake is";
cout<<Jake.getAge()<<"year old and"<<Jake.getWeight()<<"pounds weight."<<endl;
return 0;
}
【无标题】
最新推荐文章于 2024-08-16 08:17:29 发布