Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Search & Filtering

Write a C code to replace every element in a linked list with the next greatest element present in

the same list.


Complete the given code to get the output shown below:-

Base1

Base2

#include<iostream>

using namespace std;

class Base1 {

 public:

   void display()

   { cout<<"Base1"<<endl; } };

class Base2 {

public:

  void display()

   { cout<<"Base2"<<endl"; } };


class Derived: public Base1, public

Base2 {

  public:

 };

int main()

{

  Derived d;

  return 0;

}


Write the parameterized constructor for all the classes in the hierarchy.

class A

{ int a;}

Class B:public virtual A

{int b;}


Class C:public virtual A

{int c; }

Class D:public b,public C

{int d;}


Consider the class hierarchy shown below.

class A

{ int a;

protected:

int b;

public:

int c; };

class B: protected A

{ };

Class C: public B

{ };

Which data members of class A are accessible

- in class B

-in class C

-in main function

Justify your answer.


Include the function calls at appropriate places in the given program, to get the

output as shown below

In base

In derived

#include&lt;iostream&gt;

using namespace std;

class base

{ int b;

protected:

void display(){cout<<"In base\n";}

};

class derived:public base

{ int d;

  public:

void display(){ cout<<"In derived\n";}

};


int main()

{  derived D;

return 0;

}


Consider following code and state the order of execution constructors and order

of execution of destructors.

class C: public A, virtual public B

{ public:

C( ):A( ),B( )

{

cout<<”c class constructor”;

}

};


Consider following code and state the order of execution constructors and order

of execution of destructors.

class C: public A, virtual public B

{ public:

C( ):A( ),B( )

{

cout&lt;&lt;”c class constructor”;

}

};


Include the definition for the function ‘max_age’, in the program given below. The

function compares the data member age of the objects P1 and P2 and returns the

object having higher value for age.

class person

{ int age;

public:

person(int a){age=a;}

};


int main()

{ person P1(1.5);

person P2(2.5);

person P3=P1.max_age(P2);

}


Find the errors in the following program and correct them.

[Assume the necessary header files and namespaces included]

class test

{ static int x;

int y;

public:

test( ){x=0;y=0;}

static void display()

{ cout&lt;&lt;x&lt;&lt;”\t”&lt;&lt;y&lt;&lt;endl; }

void output()

{cout&lt;&lt;x&lt;&lt;”\t”&lt;&lt;y&lt;&lt;endl;}

};

int main()

{ test T1;

T1.display();

test::output();

return 0;

}


Create a class ‘Book’. Derive two classes from it namely ‘’Print_Book’ and

‘E_Book’. Store the following details about the book in the relevant classes.

Title, Author, Price, No of pages and Size in KB.

Input information for ‘m’ number of print books and ‘n’ number of eBooks and

display it.


LATEST TUTORIALS
APPROVED BY CLIENTS