In detail please and thank you. Consider the following class definitions. Write
ID: 3668084 • Letter: I
Question
In detail please and thank you.
Consider the following class definitions. Write the definition of the default constructor of smart so that the instance variables of smart arc initialized to 0 . Write the definition of the default constructor of super Smart so that the instance; variables of super Smart arc initialized to 0 . Write the definition of the member function set of smart so that the instance variables are initialized according to the parameters. Write the definition of the member function sum of the class smart so that it returns the sum o! the instance variables. Write the definition of the member function manipulate of the class super Smartso that it returns the (x + y)^z , that is, return x plus y to the power of zExplanation / Answer
I have declared constructors as per your requirement.
a) Answer:
class smart
{
publc:
void print() const;
void set(int , int);
int sum();
smart();
smart(int a,int b);
private:
int x;
int y;
int secret();
};
smart::smart() // default constructor
{
x =0;
y=0;
}
smart::smart(int a, int b) // constructor with two arguments.
{
x =a;
y =b;
}
b) Answer:
class superSmart: public smart
{
public :
void print() const;
void set(int a , int b, int c);
superSmart();
superSmart(int a , int b, int c);
private :
int z;
}
superSmart::superSmart() // default constructor.
{
z =0;
}
superSmart::superSmart(int a, int b, int c); // constructor with arguments.
{
z =c;
};
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.