✔ C++ CHAPTERS:-
1. CPP-Introduction
2. CPP-OOPs Concepts
3. CPP-Statements
4. CPP-Programming Examples
5. CPP-Operators
6. CPP-Functions
7. CPP-Classes & Objects
8. CPP-Array Of Objects
9. CPP-Constructors
10. CPP-Destructors
11. CPP-Inheritance
12. CPP-Multiple Inheritance
13. CPP Hierarchical Inheritance
14. CPP-Important Points
1. CPP-Introduction
2. CPP-OOPs Concepts
3. CPP-Statements
4. CPP-Programming Examples
5. CPP-Operators
6. CPP-Functions
7. CPP-Classes & Objects
8. CPP-Array Of Objects
9. CPP-Constructors
10. CPP-Destructors
11. CPP-Inheritance
12. CPP-Multiple Inheritance
13. CPP Hierarchical Inheritance
14. CPP-Important Points
Eg: Final exam takes marks from theory exams as well as practical exams also. So to calculate the final exam’s result we need both results[theory exam, practical exam]
Syntax :
: ,
{
//body of subclass;
}
Eg:
class Theory_Exam
{
int first, second_test;
protected:
Theory_Exam();
{
cout<<”enter total of first test marks =“;
cin>>first;
cout<<”enter total of second test marks=”;
cin>>second_test;
}
void display();
{
cout<<”first test total is=”<
cout<<”second test total is=”<
}
};
class Practical_Exam
{
intp_exam;
protected:
Practical_Exam()
{
cout<<”Enter practical exam total= “:
cin>>p_exam;
}
void display()
{
cout<<”marks of practicals exams is =”<
}
};
class Final_Exam : protected Theory_Exam, protected Practical_Exam
{
private:
int marks[3];
public:
Final_Exam();
{
int total=0;
int i;
for(i=0;i<3 i="" span="">3>
{
cout<<”Enter marks = “;
cin>>marks[i];
total=total+marks[i];
}
}
void display()
{
Theory_Exam::display();
Practical_Exam::display();
cout<<<”Total of final exam is= “<
}
};
void main()
{
Final_Exam f;
f.display();
}
Multilevel inheritance :If we have many levels in inheritance process, in which one base class becomes derived class for another next level and so on. Eg:
#include
#define SIZE 25;
class Person
{
private:
char name[SIZE];
int age;
protected:
Person();
void display();
};
Person::person()
{
cout<<”enter name = “;
cin.getline(name,SIZE);
cout<<”enter your age= “;
cin>>age;
}
void Person::display()
{
cout<<”name is= “<
cout<<”age is=”<
}
class Employee: protected Person
{
private :
float salary;
int deptno;
protected:
Employee()
{
cout<<”Enter salary = “;
cin>>salary;
cout<<”enter deptno = “ ;
cin>>deptno;
}
void display()
{
Person::display();
cout<<”salary of employes is = “ <
cout<<”department number is =” <
}
};
class Manager :protected Employee
{
private:
char deptname[SIZE];
Manager()
{
cout<<”enter department name =”;
cin.getLine(deptname,SIZE);
}
void display()
{
Employee::display();
cout<<”department name is =”<
}
};
void main()
void main()
{
Manager m;
m.display();