Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (66.57 KB, 2 trang )
<span class='text_page_counter'>(1)</span><div class='page_container' data-page=1>
Design and code a class named <b>Employee</b> that holds information for an employee. Upon
instantiation, an Employee object may receive an <b>integer</b> identifying the employee and a <b>double </b>
holding the employee’s <b>salary</b>. If the object does not receive any data, or receives invalid data,
the object adopts a <b>safe empty state</b>.
Your Employee class includes the following member functions:
• <b>void display() const</b>
o Displays the employee number followed by the salary in (NNNN) - $$$$$$$$$$
format, where NNNN denotes the employee’s number and $$$$$$$$$$ denotes
the employee’s salary.
o Displays the employee number in a field of 4 and the salary in a field of 10 to 2
decimal places.
• <b>bool valid() const</b>
o Returns true if the object holds valid data, false otherwise.
Your Employee class is supported by an <b>extraction operator</b>. For the purpose of this workshop,
you may assume that the user will input the data correctly.
Derive a class named <b>Manager</b> from <b>Employee</b> that holds information for a manager. Upon
instantiation, a Manager object may receive an <b>integer</b> identifying the <b>number of employees</b> for
Your Manager class includes the following member functions:
• <b>void display() const</b>
o Displays the employee information for the object followed by the number of
employees for which the manager is responsible in (NNNN) - $$$$$$$$$$ -
(RRR) format, where NNNN - $$$$$$$$$$ denotes employee information and
RRR denotes the number of employees.
• <b>bool valid() const</b>
o Returns true if the object holds valid data, false otherwise.
Your Manager class is supported by an <b>extraction operator</b>. For the purpose of this workshop,
you may assume that the user will input the data correctly.
The main program that uses your class is The output from your program looks
something like: