multipleinheritance - void setStudentMajor(string 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 DocumentRight 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 &lt;&lt; &quot;Student ID = &quot; &lt;&lt; A.getStudentId( ) &lt;&lt; &quot; Employment ID = &quot; &lt;&lt; A.getEmploymentId( ) &lt;&lt; endl; A.setEmploymentSalary(30000.0); A.setStudentMajor(&quot;Computer Science&quot;); cout &lt;&lt; &quot;Employee Salary = &quot; &lt;&lt; A.getEmploymentSalary( ) &lt;&lt; &quot; Student Major = &quot; &lt;&lt; A.getStudentMajor(x) &lt;&lt; endl; system(&quot;pause&quot;); }...
View Full Document

Page1 / 2

multipleinheritance - void setStudentMajor(string 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