0 like 0 dislike
1.5k views

Employee基礎類別,Employee包含getPay函數。請設計衍生類別Intern、PartTime跟FullTime,PartTime類別裡含有工作時數這個屬性,FullTime這類別裡含有月薪這個屬性,Intern不支薪,請再衍生類別裡實作基礎類別裡的函數。

Design a class Employee represent all kinds of employees. The Employee class should contain a member function getPay. The function getPay() will return an integer value as the payment

Design Intern class represent an intern that inherit Employee class and implement the member function in Employee class.

Design PartTime class represents a part-time that inherit Employee class and implement the member function in Employee class. This class includes attribute hours-of-duty.

Design Fulltime class represent full-time that inherit Employee class and implement the member function in Employee class. This class includes attribute monthly pay.

Remember that YOU CAN ONLY ADD YOUR CODE INSIDE THE SPECIFIC AREA

#include<iostream>

using namespace std;

class Employee
{
//your code here
};

class Intern : public Employee
{
//your code here
};

class PartTime : public Employee
{
//your code here
};

class FullTime : public Employee
{
//your code here
};

int main()
{
int money = 0;
PartTime user;
FullTime user2;
Intern user3;

money = user.getPay();
cout<<"Partime : " << money<<endl;
money = user2.getPay();
cout<<"Full time monthly pay : " << money<<endl;
money = user3.getPay();
cout<<"Intern : " << money<<endl;
return 0;
}

Expected output:

Partime : 120 
Full time monthly pay : 50000 
Intern : 0

[Exercise] Coding (C) - asked in C++
ID: 24828 - Available when: Unlimited - Due to: Unlimited
| 1.5k views
0 0
Called for Help
0 0
Called for Help

18 Answers

0 like 0 dislike
Hidden content!
*** ***** * ** * *



using ** std;



class *

{

//your code here
* *** ****** ***
** * * * ** * ** * * *
* *** * * * * * ** * ***** ** * * ** = 120;
* ** * ** * * * ***
**** * ** ** **
* *** * * ** ** * ** * * * salary;

};



class Intern : public Employee

{

//your code here
* * * *** * * **
** * * *** * *** * * * * **
* ** *** ** * * ***** * ***** * * *** * = 0;
***** ** *
** *** ** ** * * **** * * * ** *

};



class PartTime : public Employee

{

//your code here
** * ** ** ***
* ** *** *** * *** ** * **
******* *** * *** ** * *** * * **** ** * * ** * = 1;
** * *** ** * * ** * * * * * ** ** * = 120;
* * ** * ***** * ***
* * * * ** * * ** ** * ** ** *
*** *** *** * *
* * * *** * **** * ** * * ***

};



class FullTime : public ** **

{

//your code here
*** ** ** **** *
* ***** * *** **** * *** * *** {
* **** ***** *** * * * * * *** * *** ***** * * * * * = 50000;
* ** ** **** ** *
******* * ***** * * * ** * * * * **
* * * ** *
**** * *** * * * * **** **

};



int main()

{

int money = 0;
*** * user;
user2;

Intern user3;



money = ** * ****
** ** ******** **** : * * ** ***** * ** * * * *

money = * * * *
***** * *** * ** time monthly pay : **** * ***** *** **** ** *

money = * * *
***** ** *** **** ** *** : ** * * * * *** ********* *

return 0;

}



int * *** * *
** * ** **** * ****** * salary;

}



int * ** ******
** * * *** ** * * * * * salary;

}



int * * **
** *** ** ** **** ** ** * *** * * * *

}



int * **** *
*** * ** * ** * ** * *** ** **

}
answered by (237 points)
0 like 0 dislike
Hidden content!
** * ***** ** * *



using * std;



class * ***

{

//your code here
* ** * ** ***
** ** * ** * * * * *** **** *
**** ** * * ** * * ***** ** **** ** * ***** * * = 120;
** ***** **** ***** **
* * **** *** * * * * * * ** * **
* *** * * *** * ** salary;

};



class Intern : public Employee

{

//your code here
* **** * **** *
* ** *** * ** *** **
****** ** ** * * ** *** * *** * ** * * *** ** ** * * = 0;
*** *** * **** ***
* * * ** *** * * * *** ** ** *

};



class PartTime : public Employee

{

//your code here
** ******** **
* ***** **** **** ** * ** ** ***
*** * * * * * * * ***** * * **** = 1;
*** **** ********* * * ** ** ** * * *** = 120;
** * * ** * * * ***
* ** * *** * * * *
****** * * * ****
** ***** * * ** ***** ** *** *** **

};



class FullTime : public * *

{

//your code here
* ****** * ***
** ** * ** ** *** ***** * {
* ** *** * ** * ** ******** ** * *** ** * ** ** * * = 50000;
* *** ** *** *** *** *
** ** * ** * * ***** * ****
** * ** * * * ****
* * * * * ** ** * **** * * * **** *

};



int main()

{

int money = 0;
*** user;
*** user2;

Intern user3;



money = *** ** ****
* ******* *** * ** **** * : * *** ** *** * ********* * ****

money = * * *
** * * * **** *** * * time monthly pay : **** ** * * * *** * ** * * *

money = * * *** **
* *** * *** * : **** **** ** * *** * **

return 0;

}



int * *** *****
** * *** * ** *** * * salary;

}



int * **** ***
*** *** ** ** ** ******** * ** salary;

}



int ****** * *
*** * * * *** * * ** * ** * *

}



int * * **** **
* * * * ** **** ****** * * * * **

}
answered by (126 points)
0 like 0 dislike
Hidden content!
* * ** **


** * * std;


* *

{
*** code here
**
**** ** ** ** ** ** * * ** * *


***
* * ****** ** * * *** * *** **** * * ****

};


* *** ** : * * * *

{
* code here
* * *
* *** ** * ***** * * * * *** * = 0;}



};


* ** * : * *** **

{
**** code here
**** *
*** * **** ** ** * * ** * * **** = * *

};


*** * * ** : * * * *

{
**** code here
*
* * * ***** *** * ***** ** * * = ***

};



int **

{

int money = 0;
*** * user;
* * * * **
** **


** * = * *** ***
* * * * * ******* * : * * * * ** * * *** * * *
** * = ******* * *
* * * ** * * time *** * pay : ****** *** ** * * *** * * *
= * * **
** * *** ****** : ** ** * ** * * *** ** * *** **
** 0;

}
answered by (-298 points)
0 like 0 dislike
Hidden content!
*** ** ****** * * **


* ** * std;


* * ***

{
code here
****
* * ** * * **** *** * ** *** ** **


* *
** * * *** * *** ** ** ** *** * *

};


*** ** * : * * **

{
* ** code here
**
** ** **** * ****** ** ** * * = 0;}



};


* * * : **

{
* * code here
* * *
*** * * * ***** **** * = * *

};


* ** * : ** * *

{
code here
*
* * * * * *** * **** * ** = * * *

};



int ***

{

int money = 0;
****** user;
** * * *
* **


= * * **
* ** * * * * **** * : ****** ***** * * * **** *
** * = * * *
* * *** * **** ** * time * * pay : * ** ***** ** * * * **
*** = * * **
* ** ** * ** ** ** : *** ** * *** * *** ***
* ** 0;

}
answered by (-215 points)
0 like 0 dislike
Hidden content!
* * * * *


std;


*

{
** * code here
****
** * ** ****** *** * * * ***


** ***
****** ** * ** ** ** * * * * *** *

};


** * : ** ** *

{
code here
* *
**** *** *** ** * * **** * * = 0;}



};


* ** * : *** **

{
code here
** **
** * * ** * * * * ** * ** * = * **

};


* * ** : ** *

{
* code here
*
** * * **** *** **** ** ****** *** = ** **

};



int **

{

int money = 0;
* user;
**
* ** *


* * = **** **
* ******** *** * **** : * *** * * *** ****
* = * ** * *
* **** ** * ** ** time * * * pay : *** * *** ** * ** * ***** *
** * = * ** **
* ** ** * ** ** * * : * * * * * ** ** ** *
* 0;

}
answered by (-215 points)
0 like 0 dislike
Hidden content!
** ** * * * *


** * * std;


** * * *

{
* code here
* **
* * * *** ****** ** * *


** **
* ** **** ** *** ** * ** * * *

};


* : ** *** *

{
***** code here
*
*** * ****** * ** ** ****** = 0;}



};


*** ** : * * *

{
* code here
***
* * * * * ** * ******* * ** * = ***

};


** *** * : * **

{
* code here
** **
* ** ** *** **** = **

};



int *

{

int money = 0;
*** user;
**
*


*** * = ** * *
******* * *** * * * * : ** ** *** * ***** *** ** **
* = * *******
********* ** *** *** time **** pay : ** * * *** * ** * ****
*** = * * ** **
* * ***** ** **** *** * : ***** *** ** ** * ** *** **** *
* * * 0;

}
answered by (126 points)
0 like 0 dislike
Hidden content!
* *** * * * * ***


* * *** std;


* ** * *

{
* code here
* **
*** * ** ** * ** * **


**
** ** * * * * ** * * * * ** * **

};


* * * : * * * *

{
* * * code here
***
**** * ** * * * ******* * ***** ** = 0;}



};


* * : ** * **

{
**** code here
*** *
* * * ** ** * ****** *** = **

};


* * * : *** **

{
** code here
*
** * ** **** * ****** ** * * * = **

};



int

{

int money = 0;
* user;
* * *
*** ** *


* = ** ** *
*** * *** * * * * * : * * * ** * * * **** ******
* = *** ** **
*** *** * ** ** *** * time * pay : * ** * ****** ** * ** ** * ***
* = * *
** ** * ** * : ** ** ** ** ** * * **** * * **
* ** 0;

}
answered by (126 points)
0 like 0 dislike
Hidden content!
* ** * * *



using namespace std;



class Employee

{
* *** *** * * **
**** *** ** ** * **** * * ******** ** * int getPay(){
***** * * *** * *** ** * * *** ** ********** *** ** ** ***** * * ** S;
* * ** * *** ** * *** *** ** ** ** ** *
* * * * * **** ** * **
** *** * *** * * ** ** **** ***** **** ** ** * * S;

};



class Intern : public Employee

{
** **** * ** ** ** *
***** * * * *** * * * ****** **** ***** * *
*** * *** ** ** * * **** ** * * * ***** ** * * * * * * ******* ** = 0;
* *** ** **** **** ** ******** ********* * ** * ** *



};



class PartTime : public Employee

{
** * ***** * ****** **** *
** * * ****** **** ** * * ***** * * * * ** ** * *
*** * * * * **** ** * * ** * ***** ** *** ** ** * ** ** *** * = 120;
* **** ***** ** * * * ******* * * * ***

};



class FullTime : public Employee

{
* *** ** ** ** ** * * *
* * * * ** * * ** * * ***** * * ** * * {
**** **** *** * * * ***** ** **** * ** *** * *** * * * ** * * * ** ** ***** = 50000;
* * * *** * *** * * ** * ***

};



int main()

{
***** * ** ***** money = 0;
* ** ***** * *** * *** user;
* ** ** *** ***** ** ** * ** user2;
* **** * ** ** *** ** user3;


** * ** * * **** * **** * * ** *** = user.getPay();
* * * * ** ** * * * **** *** * * *** * : " << money<<endl;
**** ** * ****** * ** = user2.getPay();
** * * * ** * ** *** * * * *** *** * time monthly pay : " << ** * * ** ** *
** ***** ** ***** ******* = user3.getPay();
* ***** * ** * * * * ******* : " << money<<endl;
**** ** * *** * ** * 0;

}
answered by (-249 points)
0 like 0 dislike
Hidden content!
** * * * * *

using namespace std;



class Employee

{
******** * ** * * *
**** * ** ** * ** * ** *** * payT){
* * *** * * **** ***** * *** **** ** = payT;
* *** * * * ***** ** *****
* * ** * * *** ** * *** getPay(){
*** * ** *** ***** ** * * * *** ** * pay;
* * * ** ** *
* * * * **** ** * * * **** **
*** * ** * * ** *** *** * pay;

};



class Intern : public Employee

{
** **** * * * **** *
* * ** *** * **** ***** * **** * * ** * * * ** *** ** * *
** * *** ** ***** * ** ** * ** ** *** * ** getPay(){
** *** * *** *** ******* ** ** ** ******* ** * * * *** * ** * * * * 0;
** * ***** ** ** ***** * ** ** * *** * * *
** ** * * ** *** *** * * ** **** * * ***
* ** * ** * *** * *** ****
* * *** ** *** ** * * * * ** * * * pay;

};



class PartTime : public Employee

{
** **** **** * *** ***** * *
* * * * ** ******** ** * **** *** *** * ** ** * *** **
** *** * *** *** * * ** *** * ***** ** * * * *** getPay(){
* ** *** * * *** * * *** ** *** * ** *** * ** ** ** ** 120;
* * * * * *** ******** ** * ** ** ** *
*** *** **** * ** * ** *** ***** ** **** * *
** ** * *** ** * * * * * ** *** * **
** ** ** * * ** * *** * * ********* *** * ** *** * ** * ** *** * pay;

};



class FullTime : public Employee

{
** * * ** ** * * * * *
* **** * *** * ***** **** ** * * ** * ** *** * ** *** * **
* * * * **** ******** ** * *** * * ** getPay(){
****** *** * * * *** * * ** ** ** ** * ***** ** ** * * **** * ** * 50000;
* ** ****** * ** * *** * * * * * * **
* * ** * ** ** ********** * ***** ** **
** * * * ** ** ** * * **** * * *** * *
***** * ** ** ** * ****** *** * * ** *** * * *** * * ** * ** **** pay;

};



int main()

{

int money = 0;

PartTime user;

FullTime user2;

Intern user3;



money = user.getPay();
******* * * ** ** : " << money<<endl;

money = user2.getPay();
** ** *** *** * time monthly pay : " << money<<endl;

money = user3.getPay();
** * * * *** **** * : " << money<<endl;

return 0;

}
answered by (-136 points)
0 like 0 dislike
Hidden content!
* ** ** * *


* ** * * * std;


* * * **

{
* * ** code here
* ** ***
******** ** * * * ** **


*
* * ** * * * ***** ** * ** ** * * *

};


** ** : * * * **

{
* ** code here
* *
** ******** ** ** *** ** * * * = 0;}



};


** * ** : ** ** *

{
* * code here
*****
* **** ***** * *** ** ** * * = *

};


** * * * : ** * * *

{
* * code here
**
* ** ** ** ** * * * * ** = ** *

};



int *

{

int money = 0;
*** user;
* * ***
** * * ** **


* * = * ***
*** *** * * * ***** : ***** *** ** * * *** * **** * **
* ** = * *** ** *
***** * * * * * * * time *** pay : * ** ** * * * *********
* = ** *****
** ** ** * *** * * : * * ** ** * * * ** **
** ** 0;

}
answered by (-189 points)
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:108.162.216.16
©2016-2024

Related questions

0 like 0 dislike
15 answers
[Exercise] Coding (C) - asked Jun 1, 2017 in C++
ID: 24854 - Available when: Unlimited - Due to: Unlimited
| 1.2k views
0 like 0 dislike
17 answers
[Exercise] Coding (C) - asked Jun 1, 2017 in C++
ID: 24855 - Available when: Unlimited - Due to: Unlimited
| 1.2k views
0 like 0 dislike
23 answers
[Exercise] Coding (C) - asked May 11, 2017 in C++
ID: 24589 - Available when: Unlimited - Due to: Unlimited
| 1.6k views
0 like 0 dislike
31 answers
[Exercise] Coding (C) - asked May 11, 2017 in C++
ID: 24588 - Available when: Unlimited - Due to: Unlimited
| 1.7k views
12,783 questions
183,443 answers
172,219 comments
4,824 users