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

given the piece of code int a[50]; int *pa; pa=a; to access the 6th element of the array which of the following is incorrect? a.*(a+5) b.a[5] c.pa[5] d.*(*pa + 5)

6 Answers   amu, TCS,


write a programe to find the factorial of given number using recursion

3 Answers  


How do I round numbers?

0 Answers  


What is the use of structure padding in c?

0 Answers  


State two uses of pointers in C?

0 Answers   Aspire, Infogain,






Write a program of advanced Fibonacci series.

0 Answers   Aspiring Minds,


Is there any possibility to create customized header file with c programming language?

0 Answers  


Where in memory are my variables stored?

0 Answers  


Program will then find the largest of three numbers using nested if-else statements. User is prompted to enter three numbers. Program will find the largest number and display it on the screen. All three numbers entered by the user are also displayed. If user enters 21, 33, and 5, the output should be as follows: You entered: 21, 33 and 5. The largest number is 33.

0 Answers  


Find greatest number out of 10 number without using loop.

5 Answers   TCS,


What are the different types of pointers?

4 Answers   HCL, TCS,


Can we declare variable anywhere in c?

0 Answers  


Categories