VC++ 2010, 出现错误,error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
具体代码如下,来源自C++ primer Plus 第五版中文版 P429,希望大家给看一下usett.cpp
#include<iostream>
#include"tabtenn0.h"
int main(void)
{
using std::cout;
TableTennisPlayer player1 { "Chuck","Blizzard",ture);
TableTennisPlayer player2 { "Tara","Boomdea",false);
player1.Name();
if(play.HasTable( ))
cout<<":has a table.\n";
else
cout<<":hasn't a table.\n";
player2.Name();
if(player2.HasTable())
cout<<":has a table";
else
cout<<":hasn't a table .\n";
return 0;
}
tabtenn0.cpp
#include"tabtenn0.h"
#include<iostream>
#include<cstring>
TableTennisPlayer::TableTennisPlayer(const char* fn,const* ln,bool ht)
{
std::strncpy(firstname,fn,LIM-1);
firstname[LIM-1] = '\0';
std::strcpy(lastname,ln,LIM-1);
lastname[LIM-1] = '\0';
hasTable = ht;
}
void TableTennisPlayer::Name( )const
{
std::cout<<lastname<<","<<firstname;
}
tabtenn0.h
#ifndef TABTEN0_H_
#define TABTEN0_H_
class TableTennisPlayer
{
private:
enum{LIM =20};
char firstname[LIM];
char lastname[LIM];
bool hasTable;
public:
TableTennisPlayer(const char* fn = nullptr,const char* ln = nullptr,bool ht = false);
void Name ()const;
bool HasTable( ) const { return hasTable;};
void ResetTable (bool v) {hasTable = v;};
};
#endif