Define the staff (Employee) class, which derives the Saleman (salesperson) class and the manager (manager) class, respectively, and the Saleman (salesperson) class and manager (manager) classes derive new classes using multiple inheritance staff Salemana

Source: Internet
Author: User

Requirements:

(1) The data members included in the staff class are numbered (num), name (name), attendance (rateofattend), base salary (Basicsal), and bonus (prize). The Saleman class also includes a data member salesperson percentage (deductrate) and personal sales (Personamount), which also includes the data member Manager royalty ratio (totaldeductrate) and the total sales in the manager class ( TotalAmount). No other data members are included in the Salemanager class.

(2) The wage formula for all types of personnel is as follows:

Employee Real wages = Basic Salary + Bonus * Attendance

Salesperson's Real salary = Basic Salary + Bonus * attendance + personal Sales * Percentage of sales Staff

Manager Real Salary = Basic Salary + Bonus * attendance + total Sales * Percentage of the manager's commission

Sales Manager Real Salary = Basic Salary + Bonus * attendance + Personal Sales * Sales Commission ratio + total sales * Percentage of commission

(3) Each class has constructors, outputs basic information functions (output) and output real-wage functions (outputwage).



#include "iostream" USINGNAMESPACESTD; classstaff{Private:intnum charname[18]; doublerateofattend; intbasicsal; intprize; Public:staff (Inta,char*b, doublec,intd,inte): Num (a), Rateofattend (c), Basicsal (d), Prize (e) {strcpy (name,b);} voidoutput () {Cout<<num << "<<name<<" "<<rateofattend<<" "<<basicSal<<" "<<prize<<" "; } Doubleoutputwage () {return (basicsal+prize*rateofattend);}}; classsalemen:virtualpublicstaff{private:doubledeductrate; doublepersonamount; Public:salemen (Inta,char*b,doublec , Intd,inte,doublef,doubleg): Staff (A,b,c,d,e), Deductrate (f), Personamount (g) {}; Voidoutput () {staff::output (); cout<<deductrate<< "<<personAmount<<";} voiddisplay () { cout<<deductrate<< "" <<personAmount<< ""; } doubleoutputwage () {return (Staff::outputwage () +deductrate*personamount);}}; classmanager:virtualpublicstaff{private:doubletotaldeductrate; Doubletotalamount Public:manager (Inta,char*b,Doublec,intd,inte,doublef,doubleg): Staff (A,b,c,d,e), Totaldeductrate (f), TotalAmount (g) {}; Voidoutput () {staff::output (); cout<<totaldeductrate<< "" <<totalAmount<< ";} voiddisplay () {cout<<totaldeductrate<< "" <<totalAmount<< "";} Doubleoutputwage () {return (Staff::outputwage () +totaldeductrate*totalamount);}; Classsalemanager:publicsalemen,publicmanager {Public:salemanager (Inta,char*b,doublec,intd,inte,doublef,doubleg, Doubleh,doublei): Salemen (A,b,c,d,e,h,i), Manager (A,b,c,d,e,f,g), Staff (a,b,c,d,e) {} voidoutput () {staff::output (); Salemen::d isplay (); Manager::d isplay (); } doubleoutputwage () {return (Salemen::outputwage () +manager::outputwage ()-staff::outputwage ());}; Voidmain () {Staffa (1, "Liu", 1,1000,500); A.output (); A.outputwage (); cout<<endl; Salemenb (2, "L", 0.5,1000,500,5000,0.5); B.output (); B.outputwage (); cout<<endl; MANAGERC (3, "pp", 0.5,1000,500,5000,0.5); C.output (); C.outputwage (); cout<<endl; Salemanagerd (4, "P",0.5,1000,500,0.5,10000,0.5,3000); D.output (); D.outputwage (); cout<<endl; }

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.