Hello Everybody
I tried this code. Code gives 0 warning and 0 errors. I tested under Turbo C++ environment. My Question is How Constructor of all classes is called without creating an object? I know once constructor of class C is called it is automatically called upper class’s constructor. Basic question is how Constructor of class C is called with creating an object of that class?
**********CODE**********
#include<iostreams.h>
#include<conio.h>
#include<stdio.h>
class A
{
public :
A()
{
cout<<"A\n";
}
};
class B : public A
{
public :
B()
{
cout<<"B\n";
}
};
class C : public B
{
public :
C()
{
cout<<"C\n";
}
};
void main()
{
clrscr();
C();
getch();
}
**********OUTPUT**********
A
B
C