C++ 意外的非限定id';之前的签名和初始值设定人

C++ 意外的非限定id';之前的签名和初始值设定人,c++,C++,我收到的错误消息说,应该是不合格的id或初始值设定项,和im不明。它以前是工作的,同样的代码,但现在不是了 #ifndef MYCLASS_H #define MYCLASS_H #include <iostream> using namespace std; class Bank { public: Bank(); void setaccount(string a){ //unqualified id before { a

我收到的错误消息说,
应该是不合格的id或初始值设定项,
和im不明。它以前是工作的,同样的代码,但现在不是了

#ifndef MYCLASS_H
#define MYCLASS_H
#include <iostream>
using namespace std;


class Bank
{
    public:
       Bank();
       void setaccount(string a){ //unqualified id before {
          account = a;
       }
    }
    string getaccount() { // expected initializer before getaccount
        return account;
    }

private:                  // unqualified id before private
    string account;


}; // expected declaration 

#endif // MYCLASS_ 
\ifndef MYCLASS\u H
#定义MYCLASS_H
#包括
使用名称空间std;
班级银行
{
公众:
银行();
void setaccount(字符串a){//{
账户=a;
}
}
字符串getaccount(){//应为getaccount之前的初始值设定项
返回帐户;
}
private://private之前的非限定id
字符串帐户;
}; // 预期申报
#endif//MYCLASS\u

您使用的是
std::string
,但未包含其标题。加

#include <string>
#包括
到你的档案


并摆脱使用名称空间std的
,按原样。

修复了格式设置并使错误非常明显