人数不定的工资类
来源:互联网 发布:mac如何批量删除照片 编辑:程序博客网 时间:2024/05/16 00:57
/* *Copyright(c)2016,LynseyListening *All rights reserced. *文件名称:listening.cpp *作者 :陈旭 *完成日期:2016.6.1 *版本号 :codeblocks 16.01 */ #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;}
运行结果:
<img src="http://img.blog.csdn.net/20160601190821491" alt="" />
0 0
- 人数不定的工资类
- 人数不定的工资类
- 人数不定的工资类
- 人数不定的工资类
- 人数不定的工资类
- 人数不定的工资类
- 人数不定的工资类
- 人数不定的工资类
- 人数不定的工资类
- 人数不定的工资类
- 人数不定的工资类
- 人数不定的工资类
- 人数不定的工资类
- 人数不定的工资类
- 人数不定的工资类
- 人数不定的工资类
- 人数不定的工资类
- 人数不定的工资类
- XMLHTTP中readState与status的状态值
- autoconf 和 automake 生成 Makefile 文件
- Spark RPC阅读笔记(初稿)
- 统计字符串中的单词数(24)
- 如何在Windows7 设置node的环境变量NODE_ENV=production
- 人数不定的工资类
- 使用IOS企业版证书发布应用
- 第18课:Spark Streaming中空RDD处理及流处理程序优雅的停止
- 实用的 Python —— 使用虚拟环境 virtualenv(Linux)
- selenium2笔记
- JS小数运算出现多位小数的问题
- 深入学习java并发编程:内存模型(一)基础
- 第十一周项目训练8.2 圆,圆柱类族的设计
- $http