Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Student & Staff Details */
- /* Language: C++ */
- #include <iostream.h>
- #include <conio.h>
- class base
- {
- protected:
- char name[30];
- char address[150];
- public:
- base(){}
- };
- class student:private base
- {
- private:
- float marks;
- public:
- student(){}
- void get_details()
- {
- fflush(stdin);
- cout<<"\nEnter the Name of the Student: ";
- cin.getline(name,30);
- cout<<"\nEnter the Address: ";
- cin.getline(address,150);
- cout<<"\nEnter the Percentage of Marks Scored: ";
- cin>>marks;
- }
- void display_details()
- {
- cout<<"\nName: "<<name;
- cout<<"\nAddress: "<<address;
- cout<<"\n Percentage: "<<marks<<"%";
- }
- };
- class staff:private base
- {
- private:
- float salary;
- public:
- staff(){}
- void get_details()
- {
- fflush(stdin);
- cout<<"\nEnter the Name of the Staff: ";
- cin.getline(name,30);
- cout<<"\nEnter the Address: ";
- cin.getline(address,150);
- cout<<"\nEnter the Salary: ";
- cin>>salary;
- }
- void display_details()
- {
- cout<<"\nName: "<<name;
- cout<<"\nAddress: "<<address;
- cout<<"\n Salary: "<<"Rs."<<salary;
- }
- };
- int main()
- {
- system("cls");
- student student1;
- staff staff1;
- cout<<"\n\nEnter Details for the Student: \n";
- student1.get_details();
- cout<<"\n\nEnter Details for the Staff: \n";
- staff1.get_details();
- cout<<"\n----------------------------------------------------------\n\n";
- cout<<"\nDetails of the Student are: ";
- student1.display_details();
- cout<<"\n----------------------------------------------------------\n\n";
- cout<<"\nDetails of the Staff are: ";
- staff1.display_details();
- cout<<"\n----------------------------------------------------------\n\n";
- getch();
- return 0;
- }
Add Comment
Please, Sign In to add comment