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

a number whose only prime factors are 2,3,5, and 7 is call humble number,,write a program to find and display the nth element in this sequence.. sample input : 2,3,4,11,12,13, and 100.. sample output : the 2nd humble number is 2,the 3rd humble number is 3,the 4th humble number is ,the 11th humble number is 12, the 12th humble number is 14, the 13th humble number is 15, the 100th humble number is 450.

4822


What is difference between structure and union with example?

830


Explain how can a program be made to print the name of a source file where an error occurs?

956


How can I find the modification date of a file?

967


cin.ignore(80, _ _);This statement a) ignores all input b) ignores the first 80 characters in the input c) ignores all input till end-of-line d) iteration

877


any limit on the number of functions that might be present in a C program a) max 35 functions b) max 50 functions c) no limit d) none of the above

838


Hai sir, I had planned to write the NIC scientific engineer exam , plz post the sample question......

1977


the portion of a computer program within which the definition of the variable remains unchanged a) mode b) module c) scope d) none

843


swap 2 numbers without using third variable?

889


What are the different file extensions involved when programming in C?

1018


What is Dynamic memory allocation in C? Name the dynamic allocation functions.

956


What is a wrapper function in c?

846


What is the difference between a function and a method in c?

814


What is the size of empty structure in c?

820


Here is a good puzzle: how do you write a program which produces its own source code as output?

857