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
Can you please explain the difference between syntax vs logical error?
why do some people write if(0 == x) instead of if(x == 0)?
What is pointer to pointer in c language?
to print the salary of an employee according to follwing calculation: Allowances:HRA-20% of BASIC,DA-45% of BASIC,TA-10%. Deductions:EPF-8% of BASIC,LIC-Rs.200/-Prof.Tax:Rs.200/- create c language program?
What is void main ()?
How can this be legal c?
When should a far pointer be used?
Write a C/C++ program to add a user to MySQL. The user should be permitted to only "INSERT" into the given database.
Why is this loop always executing once?
Write a program that takes a 5 digit number and calculates 2 power that number and prints it(should not use big integers and exponential functions)
What is the main difference between calloc () and malloc ()?
What is wrong with this declaration?
please explain every phase in the "SDLC" in the dotnet.
Explain 'far' and 'near' pointers in c.
How can I do graphics in c?