944,017 Members | Top Members by Rank

Ad:
  • C Discussion Thread
  • Unsolved
  • Views: 1497
  • C RSS
Jul 1st, 2006
0

Hard to understand "Inheritance"

Expand Post »
I have hard time understaning of what is Inheritance?

Can someone help on this?
Similar Threads
Reputation Points: 10
Solved Threads: 1
Newbie Poster
jitterson is offline Offline
24 posts
since Jun 2006
Jul 1st, 2006
0

Re: Hard to understand "Inheritance"

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.
Moderator
Reputation Points: 572
Solved Threads: 115
Mentally Challenged Mod.
WolfPack is offline Offline
1,559 posts
since Jun 2005
Jul 3rd, 2006
0

Re: Hard to understand "Inheritance"

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....
Reputation Points: 113
Solved Threads: 20
Junior Poster
Laiq Ahmed is offline Offline
147 posts
since Jun 2006
Jul 3rd, 2006
0

Re: Hard to understand "Inheritance"

Y dont u search in web. U can get tons of material related to inheritance.
Just give the string "Inheritance tutorials"(google)
Reputation Points: 16
Solved Threads: 3
Junior Poster in Training
dilip.mathews is offline Offline
89 posts
since Jun 2006
Jul 5th, 2006
0

Re: Hard to understand "Inheritance"

Thank you all for your prompted reply. I got it.
Reputation Points: 10
Solved Threads: 1
Newbie Poster
jitterson is offline Offline
24 posts
since Jun 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C Forum Timeline: find the cause of the error in the C prog
Next Thread in C Forum Timeline: Quadratic Equation





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC