| | |
Hard to understand "Inheritance"
Please support our C advertiser: Programming Forums - DaniWeb Sister Site
![]() |
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.
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.
バルサミコ酢やっぱいらへんで
•
•
Join Date: Jun 2006
Posts: 147
Reputation:
Solved Threads: 20
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....
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....
![]() |
Similar Threads
- google "keyword" question (Search Engine Optimization)
- system("PAUSE") (C++)
- The definiton of "Memory leaks" (C++)
- Installing New Hard Drive Help "NLTDR" Pleeeese (Windows NT / 2000 / XP)
Other Threads in the C Forum
- Previous Thread: find the cause of the error in the C prog
- Next Thread: Quadratic Equation
| Thread Tools | Search this Thread |
#include adobe ansi api append array arrays asterisks binarysearch changingto char character cm copyimagefile cprogramme creafecopyofanytypeoffileinc csyntax database directory dynamic execv feet fgets file fork framework frequency function getlasterror givemetehcodez global grade gtkgcurlcompiling hacking hardware highest histogram include incrementoperators infiniteloop input interest kernel keyboard kilometer license linked linkedlist linux linuxsegmentationfault list lists locate logical_drives looping loopinsideloop. lowest match matrix meter microsoft motherboard mqqueue number odf opensource overwrite owf pattern pdf performance pointer posix probleminc process program programming radix recursion recv repetition research reversing scripting segmentationfault sequential socket socketprograming standard string systemcall testing threads turboc unix user voidmain() wab windows.h windowsapi






