Hello, I am having some trouble with this homework question for my C++ course. Define a Pet class that stores the pet’s name, age, and weight. Add appropriate constructors, accessor functions, and...


Hello, I am having some trouble with this homework question for my C++ course.


Define a Pet class that stores the pet’s name, age, and weight. Add appropriate constructors, accessor functions, and mutator functions. Use dynamic variable for name. Also define a function named getLifespan that returns a string with the value “unknown lifespan.” Then, write big three for Pet class. (Please indicate call of copy constructor, assignment operator, and destructor)


Use following main() to test your class.(
DO NOT change the int main as any alleration will not be accepted)


int main(){
Pet p("Kitty",2,10);
cout<><><>
p1.setName("Doggy");
cout<><>
cout<><>
cout<><>
cout<><>
p2 = p1;
p2.setName("Teddy");
cout<><>
cout<><>
cout<><>
cout<><>
}





Output from main function above:

Kitty
2
10
Unknown lifespan
==> (Pet) copy constructor was called
Doggy
2
10
Unknown lifespan
==> (Pet) Assignment operator was called
Teddy
2
10
Unknown lifespan
==> (Pet) Destructor was called
==> (Pet) Destructor was called
==> (Pet) Destructor was called



Jun 10, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here