cpp13.4
来源:互联网 发布:mac快捷键怎么设置 编辑:程序博客网 时间:2024/05/26 12:01
tabtenn1.h
#pragma once#include<string>using std::string;class TableTennisPlayer{private:string firstname;string lastname;bool hasTable;public:TableTennisPlayer(const string & fn = "none",const string & in = "none", bool ht = false);void Name() const;bool HasTable() const { return hasTable; };void ResetTable(bool v) { hasTable = v; };};class Rateplayer : public TableTennisPlayer{private:unsigned int rating;public:Rateplayer(unsigned int r = 0, const string & fn = "none",const string & in = "none", bool ht = false);Rateplayer(unsigned int r, const TableTennisPlayer & tp);unsigned int Rating() const { return rating; }void ResetRating(unsigned int r) { rating = r; }};
tabtenn1.cpp
#include<iostream>#include"tabtenn1.h"TableTennisPlayer::TableTennisPlayer(const string & fn,const string & ln, bool ht): firstname(fn),lastname(ln), hasTable(ht){}void TableTennisPlayer::Name() const{std::cout << lastname << ", " << firstname;}Rateplayer::Rateplayer(unsigned int r, const string & fn,const string & ln, bool ht) : TableTennisPlayer(fn, ln, ht){rating = r;}Rateplayer::Rateplayer(unsigned int r, const TableTennisPlayer & tp): TableTennisPlayer(tp), rating(r){}
usett1.cpp
#include<iostream>#include"tabtenn1.h"int main(){using std::cout;using std::endl;TableTennisPlayer player1("Tara", "Boomdea", false);Rateplayer rplayer1(1140, "Mallly", "Duck", true);rplayer1.Name();if (rplayer1.HasTable())cout << ": has a table.\n";elsecout << ": hasn't a table.\n";player1.Name();if (player1.HasTable())cout << ": has a table.\n";elsecout << ": hasn't a table.\n";cout << "Name: ";rplayer1.Name();cout << "; rating: " << rplayer1.Rating() << endl;Rateplayer rplayer2(1212, player1);cout << "Name: ";rplayer2.Name();cout << "; Rating: " << rplayer2.Rating() << endl;system("pause");return 0;}
0 0
- cpp13.4
- cpp13.2
- 4
- 4
- (4)
- 4
- 4
- 4
- 4
- 4
- 4
- 4
- 4
- 4
- 4
- 4
- 4
- 4
- MySQL bin-log
- rac在rman备份时报错ORA-00245
- 关于git你需要知道这些
- 导入和配置第三方jar包
- 使用PullToRefresh实现下拉刷新和上拉加载
- cpp13.4
- ndroid软键盘弹出,界面整体上移的问题
- QTP自动化测试之VBScript基础(上)
- Elastic-Job - 分布式定时任务框架
- Android BaseAdapter的使用
- 谷歌chrome代理安装
- Dialog对话框使用小结,让你多点时间陪妹子
- 基础练习 回文数
- List.addAll方法——添加所有元素到列表中