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 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<iostream>

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 the code given below.

[Assume all the header files and namespaces included.]

How many times the following are invoked:

I) Default constructor

II) Parameterized constructor

III)  Copy constructor

IV) Destructor


class test

{    int a;

public:

test(){a=0;}

test(int x) {a=x;}

test(const test &T){a=T.a;}

~test(){ }

test add(test X)

{ test T;

      T.a=a+X.a;

      return 0;

}

};

int main()

{  test t1(5),t2(10),t3;

   t3=t1.add(t2);

   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”;

}

};



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<<x<<”\t”<<y<<endl; }

        void output()

        {cout<<x<<”\t”<<y<<endl;}

 };

int main()

{  test T1;

   T1.display();

   test::output();

   return 0;

}



Write a programe that will check for brackets in a mathematical expression whether it is balanced or not.

Sample Inputs : Sample Outputs:

{({})([])}} Closing bracket overflow

[{{({})([])}}] Balanced

[{{({})([])})] Unmatched

(()){{{[]}{[][]}} Opening bracket overflow


Get all the potential users. Fetch the user_ids who liked at least 2 videos published by "Disney" channel, and who did not subscribe to the channel (channel_id = 352).


Note:

  • Consider reaction_type LIKE as liked.
  • Sort the output in the descending order of no_of_likes, and then in the ascending order of potential_user_id.

Expected Output Format

potential_user_id no_of_likes



Best time to upload a comedy video:

DunkFest channel is planning to upload a video in the "COMEDY" genre

Give the channel the best suitable hour of the day when users positively engage more with comedy videos.

Note:

  • Consider positive engagement as LIKE for the videos in the "COMEDY" genre_type.
  • Consider reaction_type LIKE as liked.
  • Return the hour in the integer format

Expected Output Format

hour_of_engagement no_of_likes5...


LATEST TUTORIALS
APPROVED BY CLIENTS