of Inheritance in C++
of Inheritance in C++
PRAVEEN M JIGAJINNI
PGT (Computer Science)
MTech[IT],MPhil (Comp.Sci), MCA, MSc[IT], PGDCA, ADCA,
Dc. Sc. & Engg.
email: [email protected]
C++ Inheritance
C++ Inheritance
One of the most important concepts in object-oriented
programming is that of inheritance. Inheritance allows us
to define a class in terms of another class, which makes it
easier to create and maintain an application. This also
provides an opportunity to reuse the code functionality
and fast implementation time.
Reusability:
Inheritance helps the code to be reused in many
situations.
class MyClass
{ public:
MyClass(void) { x=0; }
void f(int n1)
{ x= n1*5;}
void output(void) { cout<<x; }
private:
int x;
};
C++ Inheritance
Inheritance Example:
int main(void)
{ sample s;
s.f(10);
s.output();
s.f1(20);
s.output();
}
Class A
Class A
Class B Class C
Class D
?
Any Questions Please
Thank You
Very Much