Get invaluable Interview and Career Tips delivered directly to your inbox. Get your news alert set up today, Once you confirm your Email subscription, you will be able to download Job Inteview Questions Ebook . Please contact me if you there is any issue with the download.
What is the difference between class and structure?
Editorial / Best Answer
sumitvProfile Answers by sumitv Questions by sumitv
Structure does support inheritance.
try out the following code.
#include<iostream>
using namespace std;
struct Base
{
int A;
};
struct Derived:public Base
{
int B;
void display();
};
void Derived::display()
{
cout<<endl<<"A = "<<A<<endl;
}
int main()
{
Derived D;
D.A = 111;
D.display();
getchar();
return 0;
}
Try out private and protected inheritance as well. It works. :)
Regards,
Sumit