multipleinheritance - void setStudentMajor(string x major=x...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
#include<iostream> #include<string> using namespace std; u class Student //base class { private: int studentid; protected: string major; public: void setStudentId(int x) { //I just defined all of my member functions within the classes studentid=x; //themselves as opposed to using class scope operators somewhere } //else because the implementation is so short for each function int getStudentId() { return studentid; } }; } class Employee //base class { private: int employmentid; protected: float salary; public: void setEmploymentId(int x) { employmentid=x; } int getEmploymentId() { return employmentid; } }; } class PartTimeStudent : public Student, public Employee //derived class { public:
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: void setStudentMajor(string x) { major=x; } string getStudentMajor(string x) { x=major; return x; } void setEmploymentSalary(float x) { salary=x; } float getEmploymentSalary() { return salary; } }; } void main( ) { string x; PartTimeStudent A; A.setStudentId(123); A.setEmploymentId(456); cout << "Student ID = " << A.getStudentId( ) << " Employment ID = " << A.getEmploymentId( ) << endl; A.setEmploymentSalary(30000.0); A.setStudentMajor("Computer Science"); cout << "Employee Salary = " << A.getEmploymentSalary( ) << " Student Major = " << A.getStudentMajor(x) << endl; system("pause"); }...
View Full Document

{[ snackBarMessage ]}

Page1 / 2

multipleinheritance - void setStudentMajor(string x major=x...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online