C++ Write the DECLARATION of a class pet as follows: (HINT: you must INCLUDE this in another file) Data member variables: species, weight, age Functions: default constructor, constructor with parameters to set all variables, print, set species, set age, set weight. Be sure to include any necessary include and using directives. 2. Write the DEFINITION/IMPLEMENTATION (write the code) of the class pet declaration in Question 1. Write the code to implement (write the code for) the functions in the class pet. Be sure to include all using, includes and other directives necessary to complete the code. 3. Extend the pet class to include the following data members and functions i.e., INHERITANCE. DEFINE AND IMPLEMENT (write the code for) the extended class. Class will represent a pet of type Canine. Member variable name (i.e., pet name), color. Include member function includes, prototypes (declaration) and code (definition): all constructor(s), set color, set name and print to extend the base class pet. Create an object of the inherited class that sets all member variables to values of your choice, i.e., use the extended class as you would in a test/client program. You do not need to write any other code in the test/client. 4. Consider the pet and extended pet classes written in the previous questions: Write the PROTOTYPE for a function that overloads the + (plus) operator to add a value (i.e., 1) to the age data member in the extended/inherited pet object. Write as a member function. Write the PROTOTYPE for a function that overloads the << (insertion) operator to print an object of the extended/inherited pet object. Write the code to create one extended/inherited pet object. Write the line of code to add 1 to the age using the overloaded + (plus) operator. Write the line of code to print the extended/inherited pet object using the overloaded << (insertion) operator. You do not need to write any code for the functions, just the prototypes. You do need to create and objects of of the inherited pet class and write the code for c and d to represent using the prototypes created in a and b. You do not need to write any #include objects, main or function calls. Do not worry about setting any values for the data members. Assume any base get functions exist, if needed
OOPs
In today's technology-driven world, computer programming skills are in high demand. The object-oriented programming (OOP) approach is very much useful while designing and maintaining software programs. Object-oriented programming (OOP) is a basic programming paradigm that almost every developer has used at some stage in their career.
Constructor
The easiest way to think of a constructor in object-oriented programming (OOP) languages is:
C++
- Write the DECLARATION of a class pet as follows: (HINT: you must INCLUDE this in another file)
Data member variables: species, weight, age
-
- Functions: default constructor, constructor with parameters to set all variables, print, set species, set age, set weight.
- Be sure to include any necessary include and using directives.
2. Write the DEFINITION/IMPLEMENTATION (write the code) of the class pet declaration in Question 1.
- Write the code to implement (write the code for) the functions in the class pet.
- Be sure to include all using, includes and other directives necessary to complete the code.
3. Extend the pet class to include the following data members and functions i.e., INHERITANCE. DEFINE AND IMPLEMENT (write the code for) the extended class. Class will represent a pet of type Canine.
- Member variable name (i.e., pet name), color.
- Include member function includes, prototypes (declaration) and code (definition): all constructor(s), set color, set name and print to extend the base class pet.
- Create an object of the inherited class that sets all member variables to values of your choice, i.e., use the extended class as you would in a test/client program. You do not need to write any other code in the test/client.
4. Consider the pet and extended pet classes written in the previous questions:
- Write the PROTOTYPE for a function that overloads the + (plus) operator to add a value (i.e., 1) to the age data member in the extended/inherited pet object. Write as a member function.
- Write the PROTOTYPE for a function that overloads the << (insertion) operator to print an object of the extended/inherited pet object.
- Write the code to create one extended/inherited pet object. Write the line of code to add 1 to the age using the overloaded + (plus) operator.
- Write the line of code to print the extended/inherited pet object using the overloaded << (insertion) operator.
You do not need to write any code for the functions, just the prototypes.
You do need to create and objects of of the inherited pet class and write the code for c and d to represent using the prototypes created in a and b.
You do not need to write any #include objects, main or function calls. Do not worry about setting any values for the data members. Assume any base get functions exist, if needed
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 2 images