/*
*copyright(c) 2014,烟台大学计算机学院
*All rights reserved
*文件名称:test.cpp
*作者:吴雨凡
*版本:v6.0
*
*问题描述:人数不定的工资类
*输入描述:
*程序输出:判断相关问题
*/
#include<iostream>
using namespace std;
class Salary
{
public:
Salary(int n);
Salary(const Salary &s);
~Salary();
void input_salary();
void show_salary();
private:
double *salary;
int number;
};
Salary::Salary(int n)
{
number=n;
salary = new double[number];
}
Salary::Salary(const Salary &s)
{
number = s.number;
salary = new double[number];
for(int i=0;i<number; ++i)
*(salary+i)=*(s.salary+i);
}
Salary::~Salary()
{
delete []salary; /
}
void Salary::input_salary()
{
int i;
cout << "请输入"<<number<<"名职工的工资:" << endl;
for(i = 0; i < number; i++)
cin >> *(salary+i);
return ;
}
void Salary::show_salary()
{
for(int i = 0; i < number; ++i)
cout << *(salary+i)<<" ";
cout << endl;
return ;
}
int main()
{
Salary s(10);
s.input_salary();
s.show_salary();
return 0;
}