第九周 项目三 人数不定工资类
2016-05-11 15:13
239 查看
问题及代码:
/*Copyright (c)2016,烟台大学计算机与控制工程学院 *All rights reserved. *文件名称:main.cpp *作 者:贾庆严 *完成日期:2016年5月11日 *版 本 号:v1.0 *问题描述:设计一个工资类(Salary),其中的数据成员包括职工人数(number,人数不定)和number个职工的工资salary,要求输入职工工资并逐个输出。 */ #include<iostream> using namespace std; class Salary { public: Salary(int n); //n为职工人数,初始化时完成空间的分配 ~Salary(); //析构函数中释放初始化时分配的空间 void input_salary(); void show_salary(); private: double *salary; int number; }; Salary::Salary(int n) { number=n; salary=new double[number]; } Salary::~Salary() { delete[]salary; } void Salary::input_salary() { cout<<"Please input ten number:"<<endl; for(int i=0;i<number;i++) cin>>salary[i]; } void Salary::show_salary() { for(int i=0;i<number;i++) cout<<salary[i]<<" "; } int main() { Salary s(10); s.input_salary(); s.show_salary(); return 0; }运算结果:
相关文章推荐
- 第九周实践项目3-人数不定的工资类
- 第九周项目3-人数不定的工资类
- 第九周项目3-人数不定的工资类
- 第九周项目3 人数不定工资类
- 第九周项目4:人数不定的工资类
- 第九周上机时间项目——项目3-人数不定的工资类
- 第九周上机实践项目 项目3-人数不定的工资类(1)
- 第九周项目3-人数不定的工资类
- 第九周项目3-人数不定的工资类
- 第九周项目三 人数不定的工资类
- 第九周项目三人数不定的工资类
- 第九周项目3-人数不定的工资类
- 第九周【项目3-人数不定的工资类】
- 第九周项目3-人数不定的工资类
- 第九周项目三人数不定的工资类
- 第九周项目三人数不定的工资类
- 第九周项目3—人数不定的工资类
- 第九周项目四 人数不定的工资类
- 第九周上机实践项目3:人数的不定工资类
- 第九周项目3-人数不定的工资类2