Question: Write a class named Dog that contains: Three member variables named breed, age, sex and maturity where breed, sex and maturity are strings and
Write a class named Dog that contains: Three member variables named breed, age, sex and maturity where breed, sex and maturity are strings and age is an integer. Accessor and mutator functions for all member variables. A default constructor that initializes all strings to the empty string and the age to zero. . A constructor that accepts breed, age, sex and maturity as arguments and initializes the corresponding member variables. A fix function that changes the sex to "fixed". An overloaded + operator. The result of adding 2 dogs together is another dog with an age of zero, maturity as "puppy", and a breed of "cross" if the two dogs being added together are of different breeds or the same breed as the dogs being summed if they are of the same breed. The resulting sex of the dog is to be female. If either of the dogs to be added together are "fixed" or both dogs are of the same sex, then the overloaded operator should simply return a default dog (one initialized with the default constructor). Note: Write class specification and implementation in files Dog.h and Dog.cpp respectively. Write a "driver" program (main() function) that creates 4 dogs (not as an array) a male golden retriever, a female labrador retriever and two fixed german shephards. The age of the dogs should all be set to 1. The maturity of the dogs should be set to "adult". Display the result of adding the golden and the lab together and the two german shephards together. I . .
Step by Step Solution
3.39 Rating (152 Votes )
There are 3 Steps involved in it
Below is the implementation for the Dog class along with the specified member functions and the main driver program Dogh ifndef DOGH define DOGH include class Dog private stdstring breed int age stdst... View full answer
Get step-by-step solutions from verified subject matter experts
