读书人

error C2088: “[”: 对于 class 非法

发布时间: 2013-02-24 17:58:56 作者: rapoo

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?

读书人网 >C++

热点推荐