第九周-不定工资数
来源:互联网 发布:mac怎么删除东西 编辑:程序博客网 时间:2024/05/14 11:20
问题及代码:
/*copyright 计算机与控制工程学院。完成日期:2016年5月4日作者:马艳艳问题描述:无;输入描述:无;输出描述:结果信息*/#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(){ cout << "职工工资清单: " ; for(int i = 0; i < number; ++i) cout << *(salary+i)<<" "; cout << endl; return ;}int main(){ Salary s1(10); s1.input_salary(); Salary s2(s1); s1.show_salary(); s2.show_salary(); return 0;}
运行结果:
0 0
- 第九周-不定工资数
- 第九周项目三人数不定的工资类
- 第九周项目三人数不定的工资类
- 第九周项目三人数不定的工资类
- 第九周项目3 人数不定工资类
- 第九周项目4:人数不定的工资类
- 第九周项目3—人数不定的工资类
- 第九周项目四 人数不定的工资类
- 第九周项目三-人数不定的工资类
- 第九周项目3-人数不定的工资类
- 第九周项目三 人数不定的工资类
- 第九周项目3-人数不定的工资类
- 第九周项目3-人数不定的工资类2
- 第九周实践项目3-人数不定的工资类
- 第九周项目3-人数不定的工资类
- 第九周【项目3-人数不定的工资类】
- 第九周项目3-人数不定的工资类
- 第九周项目3-人数不定的工资类
- android-使用AsyncTask做下载进度条
- EF框架—Code-First
- windows程序消息处理流程
- iOS开发中nil、Nil、NULL和[NSNull null]的区别
- 直接选择排序
- 第九周-不定工资数
- 16.版本控制的使用 - IntelliJ IDEA 使用教程
- 关于javaWeb的Filter过滤器
- C语言中如何避免野指针
- python2 type()函数 isinstance()函数
- s3c2440使用中断方式读取按键终端
- 素数求和问题【nyoj22】
- HDU 1546 Idiomatic Phrases Game(最短路径)DIJ算法
- 17.实时代码模板的使用 - IntelliJ IDEA 使用教程