Public base

What is wrong with the following code? (8)
class classA //Line 1

protected: //Line 2

void setX(int a); //Line 3

//Postcondition: x = a; //Line 4

private: //Line 5

int x; //Line 6

; //Line 7

. . .

int main() //Line 8

//Line 9

classA aObject; //Line 10

aObject.setX(4); //Line 11

return 0; //Line 12

//Line 13

Consider the following code: (3, 8)

class base

public:

void print() const;     

//Outputs the values of num and x.

double compute(int n);     

// returns n + manipulate(n, n);

void setNum(int a);

int getNum() const;

void setX(double d);

double getX() const;

base(int n = 0, double d = 0);

protected:

double manipulate(int a, int b);

   // returns num * a + x * b;

private:

int num;

double x;

;

class derived: public base

public:

void print() const;

  //outputs the values of instance variables.

void setZ(double t);

double getZ() const;

double compute(int a, double b);

  // returns compute(a) + z * manipulate(0, b);

derived(int n = 0, double a = 0, double b = 0);

  //Sets num = n, x = a, z = b.

private:

double z;

;

Write the definition of the function print, compute, and

manipulate of the class base.

b. Write the definition of the function print and compute of the class derived.

c. What is the output of the following C++ code? base baseObj(2, 5.5);

cout < fixed=””>< showpoint=””><>

baseObj.print();

cout <>

cout < baseobj.compute(7)=””><>

derived derivedObj(3, 1.5, 2.0);

derivedObj.print();

cout < endl;=””>

cout < derivedobj.compute(1,=”” 4)=””><>

WhatsApp
Hello! Need help with your assignments?

For faster services, inquiry about  new assignments submission or  follow ups on your assignments please text us/call us on +1 (251) 265-5102

🛡️ Worried About Plagiarism? Run a Free Turnitin Check Today!
Get peace of mind with a 100% AI-Free Report and expert editing assistance.

X