首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

error C2088: “[”: 对于 class 非法,该怎么解决

2013-02-24 
error C2088: “[”: 对于 class 非法class Controller//控制器存储账户列表和处理命令{private:const stati

error C2088: “[”: 对于 class 非法
class Controller//控制器存储账户列表和处理命令
{
private:
const static int MAX_ACCOUNTS=10;
Date date;
vector<Account*>accounts;//像容器一样存放各种类型的对象
bool end;
int num_accounts;
Account *accounts[MAX_ACCOUNTS];

public:
Controller(Date &date):date(date),end(false),num_accounts(0){}
~ Controller();
Date &getDate(){return date;}
bool isEnd(){return end;}
bool runCommand(string &cmdLine);//判断是否保存该命令
};

Controller::~Controller()//系统结束后手动删除分配的资源
{
for(int i=0;i<num_accounts;i++)
{
delete accounts[i];
}

}


ps: error C2088: “[”: 对于 class 非法(求解啊)
class
[解决办法]
delete [] accounts;
[解决办法]
啊 无视上面那个... 话说是我眼花还是你定义了两个accounts?

热点排行