Professional Documents
Culture Documents
Student name: ريغز فسوي باكع ايسا Tittle: oop (Course: second Stage:2 Lecturer name: D.dunia fadheel saffo
Student name: ريغز فسوي باكع ايسا Tittle: oop (Course: second Stage:2 Lecturer name: D.dunia fadheel saffo
1. Single Inheritance
● It’s the type that we have been using all along and it looks
something like this:
class staff
{
private:
char name[50];
int code;
public:
void getdata();
void display();};
class Person {
// Data members of person
public:
Person(int x) { cout << "Person::Person(int
) called" << endl; }
};
class Faculty : public Person {
// data members of Faculty
public:
Faculty(int x):Person(x) {
cout<<"Faculty::Faculty(int ) called"<<
endl;
}
};
class Student : public Person {
// data members of Student
public:
Student(int x):Person(x) {
cout<<"Student::Student(int ) called"<<
endl;
}
};
// multi-inherited
class TA : public Faculty, public Student {
public:
TA(int x):Student(x), Faculty(x) {
cout<<"TA::TA(int ) called"<< endl;
}
};
int main() {
TA ta1(40);
return 0;
}
3. Hierarchical Inheritance
● In this type two classes(siblings) both inherit from
one class (father)
● This type of inheritance looks like this:
4. Multiple Inheritance
● In this type of inheritance a class inherits from 2 or
more classes.
● This type of inheritance looks like this:
5. Hybrid Inheritance
● This type combine all the previous types in different
ways
● This type can look like this:
<source>