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

Where static variables are stored in c?

833


What are pragmas and what are they good for?

782


What is the correct declaration of main?

945


How many types of errors are there in c language? Explain

792


Explain how can I open a file so that other programs can update it at the same time?

905


How can I trap or ignore keyboard interrupts like control-c?

859


What do you mean by keywords in c?

923


In c programming typeing to occupy the variables in memory space. if not useing the variable the memory space is wasted.ok, how to avoid the situation..? (the variable is used & notused)

1908


An integer that indentifies the position of a data item in a sequence of data items a) value b) number c) index d) all of the above

959


How do I round numbers?

803


What is pre-emptive data structure and explain it with example?

3514


What is the scope of local variable in c?

829


What is a pointer in c?

1044


What does & mean in scanf?

866


What's the difference between constant char *p and char * constant p?

935