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
Explain the difference between null pointer and void pointer.
What is the difference between pure virtual function and virtual function?
Explain Basic concepts of C language?
Write the Program to reverse a string using pointers.
What are void pointers in c?
What is the difference between text and binary i/o?
What is meant by 'bit masking'?
What is the modulus operator?
What is unary operator?
What is the correct code to have following output in c using nested for loop?
What is use of integral promotions in c?
What is the use of header?
How can I avoid the abort, retry, fail messages?
Where define directive used?
Why is it usually a bad idea to use gets()? Suggest a workaround.