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;
}

Answers were Sorted based on User's Feedback



what is out put of the following code? #include class Base { Base() { cout<<"const..

Answer / pooja sonawane

error.
because, there is no header file.
and no ";" is given after the end of classes.

Is This Answer Correct ?    2 Yes 1 No

what is out put of the following code? #include class Base { Base() { cout<<"const..

Answer / 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

what is out put of the following code? #include class Base { Base() { cout<<"const..

Answer / anvesh

there is no include file iostream for cout
immproper ending for classes ';'

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C Interview Questions

why we are using semicolon at the end of printh statment

2 Answers   HCL,


Are local variables initialized to zero by default in c?

0 Answers  


Difference between Function to pointer and pointer to function

0 Answers  


What is a program?

0 Answers  


Explain what are the __date__ and __time__ preprocessor commands?

0 Answers  






What is the difference between realloc() and free()

1 Answers  


which will be first in c compiling ,linking or compiling ,debugging.

3 Answers   Sonata,


Why is c faster?

0 Answers  


Explain the use of function toupper() with and example code?

0 Answers  


Write a program that his output 1 12 123

0 Answers  


What's the difference between calloc() and malloc()?

4 Answers  


Can you please explain the difference between syntax vs logical error?

0 Answers  


Categories