11 Years
Discussion Span
Last Post by jitterson

What do you mean by inheritance in real life? The child gets what his parents have if they let him have it. That is the same in programming too.

If you have a class A, whose child is class B, class B gets the things class A that has been declared public or protected by the programmer. Anything declared private will not be inherited.


Inheritance simply means Reusing the Interface of the base class. Two classes have something in common for example consider the following example. There are two classess Shape(a base/parent class) and Circle(a derived/child class ) you might have guessed there is some relationship between shape and Circle. Every shape has color including circle. So if we make the interface of the shape and inherit the interface of the shape class to circle we just need to mention the information specific to Circle

class Shape {
void draw();
void fill_color();


//inheritance syntax
class Shape: public Shape {
void Set_radius();
size_t radius;

This is the simplest information i can provide hope you got the basic idea....:confused:


Y dont u search in web. U can get tons of material related to inheritance.
Just give the string "Inheritance tutorials"(google)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.