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:Kitty210Unknown lifespan==> (Pet) copy constructor was calledDoggy210Unknown lifespan==> (Pet) Assignment operator was calledTeddy210Unknown lifespan==> (Pet) Destructor was called==> (Pet) Destructor was called==> (Pet) Destructor was called
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here