第十章编程练习(7)
2016-02-05 19:37
260 查看
ff.h
function.cpp
main.cpp
#include <iostream>
#include "ff.h"
#include <cstdlib>
using namespace std;
int main()
{
Plorg pl;
pl.showpl();
cout << "Please enter your name: ";
char name[19];
cin.getline(name, 19);
Plorg sl(name);
sl.showpl();
cout << "Please enter your CL: ";
int n = 0;
cin >> n;
sl.setcl(n);
sl.showpl();
system("pause");
return 0;
}
#pragma once #ifndef ff_H_ #define ff_H_ class Plorg { private: char name[19]; int cl; public: Plorg(char p_name[19] = "Plorga", int n = 50); void setcl(int n); void showpl()const; }; #endif
function.cpp
#include "ff.h" #include <iostream> using namespace std; Plorg::Plorg(char p_name[19], int n) { strcpy(name, p_name); cl = n; } void Plorg::setcl(int n) { cl = n; } void Plorg::showpl()const { cout << "Name :" << name<<endl << "CL :" << cl<<endl; }
main.cpp
#include <iostream>
#include "ff.h"
#include <cstdlib>
using namespace std;
int main()
{
Plorg pl;
pl.showpl();
cout << "Please enter your name: ";
char name[19];
cin.getline(name, 19);
Plorg sl(name);
sl.showpl();
cout << "Please enter your CL: ";
int n = 0;
cin >> n;
sl.setcl(n);
sl.showpl();
system("pause");
return 0;
}
相关文章推荐
- Boost.Asio基础(五) 异步编程初探
- java 异常详解
- Spring的事务管理
- Java [Leetcode 190]Reverse Bits
- C语言:链表实现的一个实例
- C语言:链表实现的一个实例
- c#之new关键字
- 我的蓝桥杯历届初赛试题总结
- 《STL源代码剖析》---stl_alloc.h阅读笔记
- 错误记录--“==”与“=”错误
- Java 自定义注解详解
- Python教程学习简记4--Python 迭代(iteration)
- C++运算符重载
- 《Python核心编程》第四章:Python 对象
- 《Python核心编程》第三章:Python基础
- 在 Visual Studio 2012 中完成配置华为软件入职前练习的CppUnit测试
- Java实现数据库操作
- 《Python核心编程》第二章:Python起步
- neuq oj 1010 阶乘数列 C语言
- asp.net 导出excel