class smart
{
public :
void print () const ;
void set (int , int );
int sum ();
smart ();
smart (int , int );
private :
int x ;
int y ;
int secret ();
};
class superSmart : public smart
{
public :
void print () const ;
void set (int , int , int );
int manipulate ();
superSmart ();
superSmart (int , int , int );
private :
int z ;
};
a. Write the definition of the default constructor of smart so that the instance
variables of smart are initialized to 0 .
b. Write the definition of the default constructor of superSmart so that the
instance variables of superSmart are initialized to 0 .
c. Write the definition of the member function set of smart so that the instance
variables are initialized according to the parameters.
d. Write the definition of the member function sum of the class smart so that it
returns the sum of the instance variables.
e. Write the definition of the member function manipulate of the class superSmartso that it returns the (x + y)^z, that is, return x plus y to the power of z.
Yes, private stuff can still be used inside the class, just not outside. Please take your time to read the link I gave you, it literally says this about private members after a few lines of words.
If you prefer people explaining it, you can always watch youtube videos about how classes work =)
If you create the constructor within the class then yes that is correct, but you usually want to have the class in the .h file and the functions in the .cpp file - Watch this -