what is out put of the following code?
#include
class Base
{
Base()
{
cout<<"constructor base";
}
~Base()
{
cout<<"destructor base";
}
}
class Derived:public Base
{
Derived()
{
cout<<"constructor derived";
}
~Derived()
{
cout<<"destructor derived";
}
}
void main()
{
Base *var=new Derived();
delete var;
}

Answer Posted / kapil

There are 3 errors mainly
first header files are not included
second no semicolon at the end of class
third constructor of class cannot be private

if all these three errors are removed the output will be
constructor base
constructor derived
destructor base

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

If the size of int data type is two bytes, what is the range of signed int data type?

583


What is the purpose of clrscr () printf () and getch ()?

591


What does stand for?

590


Implement bit Array in C.

672


What are the disadvantages of c language?

614






What do you know about the use of bit field?

606


What is the difference between procedural and declarative language?

645


Write a program which returns the first non repetitive character in the string?

597


What will the code below print when it is executed?   int x = 3, y = 4;         if (x = 4)                 y = 5;         else                 y = 2;         printf ("x=%d, y=%d ",x,y);

1347


HOW TO SOLVE A NUMERICAL OF LRU IN OS ??????

2263


Why structure is used in c?

585


`write a program to display the recomended action depends on a color of trafic light using nested if statments

1629


What is getch c?

847


What is a stream in c programming?

588


FILE *fp1,*fp2; fp1=fopen("one","w") fp2=fopen("one","w") fputc('A',fp1) fputc('B',fp2) fclose(fp1) fclose(fp2)} a.error b. c. d.

1196