当前位置: 技术问答>linux和unix
救命!100分想送
来源: 互联网 发布时间:2015-07-16
本文导语: 一个类 头文件:tabtenn0.h #ifndef TABTENN0_H_ #define TABTENN0_H_ class TableTennisPlayer { private: enum {LIM=20}; char firstname[LIM]; char lastname[LIM]; bool hasTable; public: TableTennisPlayer(const char *fn,const char *ln,bool ht=false...
一个类
头文件:tabtenn0.h
#ifndef TABTENN0_H_
#define TABTENN0_H_
class TableTennisPlayer
{
private:
enum {LIM=20};
char firstname[LIM];
char lastname[LIM];
bool hasTable;
public:
TableTennisPlayer(const char *fn,const char *ln,bool ht=false);
void Name() const;
bool HasTable() const { return hasTable;};
void ResetTable(bool v) {hasTable=v;};
};
#endif
类的实现:tabtenn0.cpp
#include
#include "tabtenn0.h"
#include
using namespace std;
TableTennisPlayer::TableTennisPlayer(const char *fn,const char *ln,bool ht)
{
strncpy(firstname,fn,LIM-1);
firstname[LIM-1]i='';
strncpy(lastname,ln,LIM-1);
lastname[LIM-1]='';
hasTable=ht;
}
void TableTennisPlayer::Name() const
{
cout
头文件:tabtenn0.h
#ifndef TABTENN0_H_
#define TABTENN0_H_
class TableTennisPlayer
{
private:
enum {LIM=20};
char firstname[LIM];
char lastname[LIM];
bool hasTable;
public:
TableTennisPlayer(const char *fn,const char *ln,bool ht=false);
void Name() const;
bool HasTable() const { return hasTable;};
void ResetTable(bool v) {hasTable=v;};
};
#endif
类的实现:tabtenn0.cpp
#include
#include "tabtenn0.h"
#include
using namespace std;
TableTennisPlayer::TableTennisPlayer(const char *fn,const char *ln,bool ht)
{
strncpy(firstname,fn,LIM-1);
firstname[LIM-1]i='';
strncpy(lastname,ln,LIM-1);
lastname[LIM-1]='';
hasTable=ht;
}
void TableTennisPlayer::Name() const
{
cout