Question

In C++ 1. Define a class "Animal" which will have the follwing properties: (7) legs (int)...

In C++
1. Define a class "Animal" which will have the follwing properties: (7)

legs (int)
eyes (int)

2. Define a class "Dog" which will have two more properties and also inherites from Animal class (7)
tail (boolean)
name ()

3. Define a class "Human" which will have two more properties and inherites from Animal class (7)

Name
Language

4.In main Function (9)
Create object of each classes and print the properties of each class

Homework Answers

Answer #1

#include <iostream>

using namespace std;

class Animal {
public:
  

void seteyes(int e) {
eyes = e;
}
      
void setlegs(int l) {
legs = l;
}
      
protected:
int legs;
int eyes;
};

class Dog: public Animal {
public:
char dogname='s';
  
  
};
class Human: public Animal {
public:
char humanname='D';
char language='e';
};

int main(void) {

Dog d;
Human h;   

cout << "dogname is : " <<d.dogname << endl;
cout << "Human name is: " << h.humanname << endl;
cout << "Human Language is : " << h.language << endl;

return 0;
}

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Write the following problem in Java Create a class Dog, add name, breed, age, color as...
Write the following problem in Java Create a class Dog, add name, breed, age, color as the attributes. You need to choose the right types for those attributes. Create a constructor that requires no arguments. In this constructor, initialize name, breed, age, and color as you wish. Define a getter and a setter for each attribute. Define a method toString to return a String type, the returned string should have this information: “Hi, my name is Lucky. I am a...
Challenge: Animal Class Description: Create a class in Python 3 named Animal that has specified attributes...
Challenge: Animal Class Description: Create a class in Python 3 named Animal that has specified attributes and methods. Purpose: The purpose of this challenge is to provide experience creating a class and working with OO concepts in Python 3. Requirements: Write a class in Python 3 named Animal that has the following attributes and methods and is saved in the file Animal.py. Attributes __animal_type is a hidden attribute used to indicate the animal’s type. For example: gecko, walrus, tiger, etc....
Part 1 - LIST Create an unsorted LIST class ( You should already have this code...
Part 1 - LIST Create an unsorted LIST class ( You should already have this code from a prior assignment ). Each list should be able to store 100 names. Part 2 - Create a Class ArrayListClass It will contain an array of 27 "list" classes. Next, create a Class in which is composed a array of 27 list classes. Ignore index 0... Indexes 1...26 correspond to the first letter of a Last name. Again - ignore index 0. index...
Design a class with the following requirements: 1- give the class a name from your choice....
Design a class with the following requirements: 1- give the class a name from your choice. 2- write some code that creates three instance variables, choose a name and type for each one of them. (must have two private and one public variables) 3- Initialize the variables using two different constructors. 4- Use mutator and accessor methods (set and get) for the private data members. 5- Display the value of each member variable using a method. 6- In the main,...
Design a class with the following requirements: 1- give the class a name from your choice....
Design a class with the following requirements: 1- give the class a name from your choice. 2- write some code that creates three instance variables, choose a name and type for each one of them. (must have two private and one public variables) 3- Initialize the variables using two different constructors. 4- Use mutator and accessor methods (set and get) for the private data members. 5- Display the value of each member variable using a method. 6- In the main,...
Assignment Statement Use the skeleton file starter code (below) to create the following classes using inheritance:...
Assignment Statement Use the skeleton file starter code (below) to create the following classes using inheritance: ⦁   A base class called Pet ⦁   A mix-in class called Jumper ⦁   A Dog class and a Cat class that each inherit from Pet and jumper ⦁   Two classes that inherit from Dog: BigDog and SmallDog ⦁   One classes that inherit from Cat: HouseCat The general skeleton of the Pet, Dog, and BigDog classes will be given to you (see below, "Skeleton", but...
Language is C# 1. Create the following classes: Vessel, which is an abstract class and represents...
Language is C# 1. Create the following classes: Vessel, which is an abstract class and represents any water-going craft. Ship, which is a Vessel. Fun Fact: A Ship is any vessel that is large enough to carry smaller Boats. Boat, which is a Vessel. and Cat, which is just a cat. All Vessels should have a float speed; and string name; Ships should have an int fuel and an int maxFuel. Boats should have an int oars; Cats should have...
Create a class called BirthYear. It should only have two member, both of them arrays. One...
Create a class called BirthYear. It should only have two member, both of them arrays. One of type string called Names. The second of type int called BirthYears. in your main class create a StudentBirthYear object. Make sure both arrays are of the size 10. Add ten different names and ten different birth years. Then display each name with its birth year using only 1 for loop. (You can display in a for loop as well as a foreach loop,...
Java code Problem 1. Create a Point class to hold x and y values for a...
Java code Problem 1. Create a Point class to hold x and y values for a point. Create methods show(), add() and subtract() to display the Point x and y values, and add and subtract point coordinates. Tip: Keep x and y separate in the calculation. Create another class Shape, which will form the basis of a set of shapes. The Shape class will contain default functions to calculate area and circumference of the shape, and provide the coordinates (Points)...
C++ 5a)We have the following class: class Banana { private:      string s;      int y;...
C++ 5a)We have the following class: class Banana { private:      string s;      int y; public: bool theMemberFunc (string); void setterForS(string); // setter for s string getterForS(); // getter for s }; Instantiate a static object of Banana named co. a)int Banana; b)co.Banana = new; c)Banana = new class; d)Banana co; 5b)Code a call to function aNonclassFunction passing co. a)aNonclassFunction (co); b)aNonclassFunction (* co); c)aNonclassFunction (aGoodClass.co); d)aNonclassFunction (aGoodClass); 5c)Code the function definition for aNonclassFunction, picking up co. aNonclassFunction has...