请教 “返回数组指针” 和“数组指针赋值” 的问题
std::string* getSiteType(){
std::string *_type = new std::string[2];
int j = 0;
//Langure的定义是std::map<std::string, std::vector<FromTo *> > *Langure 并且已经初始化的, 肯定有值
for(std::map<std::string, std::vector<FromTo *> >::iterator i = Langure->begin(); i != Langure->end(); ++i){
_type[j] = i->first; //这里赋值有问题, 会出现“断错误”
j++;
}
return _type;
}
void Create(GtkWidget *vbox)
{
std::string *_Type = getSiteType();
int _typeSize = _Type->size();
int i = 0;
while(i < _typeSize){
std::string *a = _Type[i]; //这里不知道怎么把数组的元素挨个读出来
printf("111111111%s", a.c_str());
i++;
}
}
谢谢大家。