q 4
.cppp
# include <iostream>
# include "employee.h"
using namespace std;
void employee::getemployee(){
cout << "enter employee number";
cin >> employeeno;
cout << " enter compensation";
cin >> compensation;
}
void employee::showemployee(){
cout << employeeno << "\t\t$ " << compensation<< "\n";
}
main.cpp
# include <iostream>
# include "employee.h"
using namespace std;
int main()
{
employee E1, E2, E3;
E1.getemployee();
E2.getemployee();
E3.getemployee();
cout << "\nNumber\t\tCompensation\n\n";
E1.showemployee();
E2.showemployee();
E3.showemployee();
system("pause");
return 0;
}
.h
class employee{
private:
int employeeno;
int compensation;
public:
void getemployee();
void showemployee();
};
0 comments: