I have hard time understaning of what is Inheritance?

Can someone help on this?

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 {
public:
void draw();
void fill_color();

};

//inheritance syntax
class Shape: public Shape {
public:
void Set_radius();
private:
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)

Thank you all for your prompted reply. I got it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.