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

the question is that what you have been doing all these periods (one year gap)

0 Answers   HCL,


How does free() know how many bytes to free?

8 Answers  


What do you mean by dynamic memory allocation in c?

0 Answers  


What is the difference between getch() and getche()?

1 Answers   NSPL,


write a program for fibonaci series by using while loop in c?

2 Answers  


What is the c language function prototype?

0 Answers  


define switch statement?

6 Answers   CTS,


What is a good way to implement complex numbers in c?

0 Answers  


If a variable is a pointer to a structure, then which operator is used to access data members of the structure through the pointer variable?

0 Answers  


Write a c program using for loop in switch case?

1 Answers   Infosys,


write a program to concatenation the string using switch case?

0 Answers  


Explain the use of #pragma exit?

0 Answers  


Categories