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

main() { int i; printf("%d",i^i); }

1 Answers  


what is ram?

3 Answers   TCS,


How would you write qsort?

1 Answers  


The file stdio.h, what does it contain?

0 Answers  


What is a stream in c programming?

0 Answers  






how to add numbers without using arithmetic operators.

14 Answers   TCS,


In which header file is the null macro defined?

0 Answers  


How do I declare an array of N pointers to functions returning pointers to functions returning pointers to characters?

2 Answers   CMC, Wipro,


#include<stdio.h> void main() { int a=5,b=6,c; int x=(a<b)+7; int y=(x==7)*9; int z=(c=x+y)*2; printf("%h %h %h",x,y,z); } What is the output? Explain it.

8 Answers   IBM,


what is difference b/w extern & volatile variable??

6 Answers   Teleca,


Can we access RAM? How? Whats the range of access? Similarly What are other hardware we can access?

1 Answers  


how to build a exercise findig min number of e heap with list imlemented?

0 Answers  


Categories