我有一个函数如下:多线程 - 为const char数组传递作为参数
laodFunc(const map<uint16_t, string> & pClasses, const char * pFilePath);
而且我通过这种方式调用它。 ,为了运行与升压
boost::thread_group g;
stringstream myStr;
......
boost::thread *new_thread = new boost::thread(&loadFunc,classes,myStr.str().c_str());
g.add_thread(new_thread);
一个新的线程但是,当我在调用的方法显示给定的路径(字符*)我得到一个错误的内容: 路径?
我想知道的请我在做什么错在这里。 由于
这不一定的情况下,根据未显示的流量,但我敢打赌,你说得对! –
@MartinJames,b立即销毁'std :: string'。 'stringstream'的生命周期是无关紧要的。 – hmjd
@hmjd谢谢你的回答 – saloua