int main(int argc, char **argv)
{
vector<const char *> pv_in;
const char *a = "hello world";
const char *b = "hello linux";
pv_in.push_back(a);
pv_in.push_back(b);
for(int i = 0 ; i < pv_in.size() ; ++i)
qDebug()<<pv_in.at(i);
void *p = (vector<const char *> *)&pv_in;
vector<const char *> *pv_get = (vector<const char *> *)p;
for(int i = 0 ; i < pv_get->size() ; ++i)
qDebug()<<pv_get->at(i);
return 0;
}
输出:
hello world
hello linux
hello world
hello linux
这说明 vector 转成void * 然后再转成 vector 是有效的。