我有一个映射将一个字符映射到一个二维规则数组来处理该字符。以下是代码:
struct CFG //this struct is data structure to contain a context free grammar
{
vector<char> *V;
vector<char> *T;
map<char,vector<vector<rhs>*>*> *prod;
// char start;
};
int main()
{
map<char,vector<vector<rhs>*>*> *prod; //rhs is the type of each cell of the 2-d array
CFG cfg1;
cfg1.V= new vector<char>;
//We imput elements into the V array here......//
cfg1.prod= new map<char,vector<vector<rhs>*>*>;
for(int i=0;i<cfg1.V->size();i++)
{
vector<vector<rhs>*>* all_prod_of_one_nonter= new vector<vector<rhs>*>;
*(cfg1.prod)[*(cfg1.V)[i]]=all_prod_of_one_nonter; //error occurs here//////
}
}
在该行中,我标记为“发生错误”,发生以下错误:
q1.cpp: In function ‘int main()’:
q1.cpp:93:29: error: no match for ‘operator*’ in ‘**(cfg1.CFG::V + ((unsigned int)(((unsigned int)i) * 12u)))’
我使用 * 取消引用指针 cfg1.V 以便我可以使用下标表示法来访问数组单元格。如何消除错误?