Mình chạy mãi mà nó không ra không biết bị gì Luôn. Run được mà nó không ra
#include<iostream>
#include<string>
using namespace std;
int n;
class Employees{
public:
string Name;
int Year, Allowance;
virtual void input();
virtual void output();
int Total();
};
void Employees::input(){
cin.ignore();
cout<<"\nMoi Nhap Vao Ten Employees: ";
getline(cin,Name);
cout<<"Nhap Nam Vao Lam Cua Employees: ";
cin>>Year;
}
void Employees::output(){
cout<<"\nHo Va Ten: "<<Name;
cout<<"\nNam Vao Lam: "<<Year;
}
int Employees::Total(){
Allowance=100000;
if(Year <2018){
Allowance =Allowance +(20000* (2018-Year));
}
return Allowance;
}
class EmployeesProduct: public Employees{
public:
int product,total;
int Total1();
void input();
void output();
};
int EmployeesProduct::Total1(){
total= product *10000 + Total();
return total;
}
void EmployeesProduct::input(){
Employees *e=new Employees[n];
for(int i=0; i<n; i++){
cout<<"\n\tMoi Nhap Vao Employees Product "<<i+1;
(e+i)->input();
cout<<"Moi Nhap So San Pham";
cin>>(this+i)->product;
}
}
void EmployeesProduct::output(){
Employees *e=new Employees[n];
for(int i=0; i<n; i++){
cout<<"\n\t---->Employees "<<i+1;
(e+i)->output();
cout<<"\nSo Tien Tra La "<<i+1<<": "<<(this+i)->Total1();
}
}
int main(){
cout<<"Moi Nhap Vao So Luong Nhan Vien: ";cin>>n;
Employees *e=new EmployeesProduct[n];
e->input();
e->output();
delete(e);
return 0;
}
83% thành viên diễn đàn không hỏi bài tập, còn bạn thì sao?