Inheritance in OOP

আজাইরা থাকতে থাকতে হটাত্‌ মনে হইল অনেক দিন প্যানর প্যানর করা হয়। তাই চলে আসলাম আবার আমার দুনিয়ায়। আজকে আমি OOP এর Inheritance নিয়া কিছু কথা বলব। পুরাটাই বাংলায় লিখতে পারতাম,কিন্তু কতিপয় STUDENT দের আবার exam এ বাংলা লেখতে পারবে না বলে tutorial টা ইংরেজিতে দিয়া দিলাম।
এখন আসি আসল কথায়…………………।

Base-Class Access Control
When a class inherits another,the members of the base class become members of the derived class.
Class inherits uses the general form:
[code]
class derived-class:access base-class{
//body of class
};
[/code]

The access status of the base class’s members inside the derived class is determined by the access.
There are three types of access specifier.They are public,private and protected. If no access specifier is present, the access specifier is by default private.

When the access specifier for a base class is public, all public members of the base class become public members of the derived class and all protected members of the base become protected members of the derived class.

In all cases,the base’s private members remain private for the derived class and are not accessible by members of derived class.

When the access specifier for a base class is private, all public and protected members of the base class become private members of the derived class.

When the access specifier for a base class is protected, all public and protected members of the base class become protected members of the derived class.

See example from your text books for the better conception.

One Reply to “Inheritance in OOP”

  1. When the access specifier for a base class is protected, all public and protected members of the base class become protected members of the derived class.

    That’s the point! Thanks!

Leave a Reply

Your email address will not be published. Required fields are marked *