How does inheritance in C works?

Showing Answers 1 - 6 of 6 Answers

rakio

  • Jul 8th, 2007
 

By using multiple structures means structure within a structure, we can achive inheritance in C.

  Was this answer useful?  Yes

This is an example of inheritance ....



struct parent {
  int x;
  int y;
};

struct child {
  parent p1;
  int a;
  int b;
};

int main()
{
  struct child c1;
  c1.p1.x=50;
  printf("%dn",c1.p1.x);

  return 0;
}

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions