mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-12-23 09:41:36 +00:00
Remove duplicate code.
This commit is contained in:
parent
c5212932b9
commit
7bab2c5e8d
@ -289,8 +289,6 @@ public:
|
||||
|
||||
}; // 在类的定义之后,要加一个分号
|
||||
|
||||
}; // 记住,在类的定义之后,要加一个分号!
|
||||
|
||||
// 类的成员函数通常在.cpp文件中实现。
|
||||
void Dog::Dog()
|
||||
{
|
||||
@ -309,22 +307,6 @@ void Dog::setWeight(int dogsWeight)
|
||||
weight = dogsWeight;
|
||||
}
|
||||
|
||||
// 虚函数的virtual关键字只需要在声明时使用,不需要在定义时出现
|
||||
void Dog::print() const
|
||||
{
|
||||
std::cout << "Dog is " << name << " and weighs " << weight << "kg\n";
|
||||
}
|
||||
|
||||
void Dog::~Dog()
|
||||
{
|
||||
cout << "Goodbye " << name << "\n";
|
||||
}
|
||||
|
||||
void Dog::setWeight(int dogsWeight)
|
||||
{
|
||||
weight = dogsWeight;
|
||||
}
|
||||
|
||||
// 虚函数的virtual关键字只需要在声明时使用,不需要在定义时重复
|
||||
void Dog::print() const
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user