注册 登录
编程论坛 VC++/MFC

VC++ 2010, 出现错误,error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int

wangsanguo 发布于 2014-03-08 11:21, 1466 次点击
具体代码如下,来源自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
2 回复
#2
wangsanguo2014-03-08 16:39
自己找到错误了
#3
hubinyes2014-03-15 12:34
恭喜
1