Friday, 5 August 2011

Inheritance in C.


In C, Inheritance can be implemented through struct.


For example.


struct base
{
/* base class members */
}b;

struct derived
{
struct base super;
/* derived class members */
}d;

void main()
{
struct base *base_ptr = (struct base *)&d; // upcast
getch();

}

No comments:

Post a Comment