Question: C++ homework questions: So I just started learning a little bit of C++ and then I came upon these questions out of my book, and
C++ homework questions: So I just started learning a little bit of C++ and then I came upon these questions out of my book, and I am not sure how to anwser them. Thank you in advance for any help you can provide.
A. Consider the following statements:
class fruits: food { };
a. In this declaration, which class is the base class and which class is the derived class?
b. What is the type of this inheritance?
B. Consider the following class definition:
class circle class cylinder: public circle { { public: public: void print() const; void print() const; void setRadius(double); void setHeight(double); void setCenter(double, double); double getHeight(); void getCenter(double&, double&); double volume(); double getRadius(); double area(); double area(); circle(); cylinder(); circle(double, double, double); cylinder(double, double, double, double); private: private: double xCoordinate; double height; double yCoordinate; } double radius; }
Suppose that you have the declaration: cylinder newCylinder;
Write the definitions of the member functions of the classes circle and cylinder. Identify the member functions of the class cylinder that overrides the member functions of the class circle.
C. Consider the following class definitions:
class smart class superSmart: public smart { { public: public: void print() const; void print() const; void set(int, int); void set(int, int, int); int sum(); int manipulate(); smart(); superSmart(); smart(int, int); superSmart(int, int, int); private: private: int x; int z; int y; int secret(); }; };
Which private members, if any, of smart are public members of superSmart?
Which members, functions, and/or data of the class smart are directly accessible in class superSmart?
D. Consider the following class definition:
class first { public: void setX(); void print() const;
protected: int y; void setY(int a);
private: int x; };
Suppose that class second is derived from class first using the statement: class second: private first
Determine which members of class first are private, protected, and public in class second.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
