mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-12-23 23:33:00 +03:00
Remove return type from Dog class constructor and destructor, change nonexistant printDog function to print.
This commit is contained in:
parent
8dba840cfe
commit
462ac89217
@ -300,7 +300,7 @@ public:
|
|||||||
}; // A semicolon must follow the class definition.
|
}; // A semicolon must follow the class definition.
|
||||||
|
|
||||||
// Class member functions are usually implemented in .cpp files.
|
// Class member functions are usually implemented in .cpp files.
|
||||||
void Dog::Dog()
|
Dog::Dog()
|
||||||
{
|
{
|
||||||
std::cout << "A dog has been constructed\n";
|
std::cout << "A dog has been constructed\n";
|
||||||
}
|
}
|
||||||
@ -323,7 +323,7 @@ void Dog::print() const
|
|||||||
std::cout << "Dog is " << name << " and weighs " << weight << "kg\n";
|
std::cout << "Dog is " << name << " and weighs " << weight << "kg\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
void Dog::~Dog()
|
Dog::~Dog()
|
||||||
{
|
{
|
||||||
cout << "Goodbye " << name << "\n";
|
cout << "Goodbye " << name << "\n";
|
||||||
}
|
}
|
||||||
@ -332,7 +332,7 @@ int main() {
|
|||||||
Dog myDog; // prints "A dog has been constructed"
|
Dog myDog; // prints "A dog has been constructed"
|
||||||
myDog.setName("Barkley");
|
myDog.setName("Barkley");
|
||||||
myDog.setWeight(10);
|
myDog.setWeight(10);
|
||||||
myDog.printDog(); // prints "Dog is Barkley and weighs 10 kg"
|
myDog.print(); // prints "Dog is Barkley and weighs 10 kg"
|
||||||
return 0;
|
return 0;
|
||||||
} // prints "Goodbye Barkley"
|
} // prints "Goodbye Barkley"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user