0
访问下面的代码崩溃我的程序:挥发性成员不能由成员函数
#include <string>
#include <vector>
class test {
volatile std::vector<std::string> wtf;
public:
test() {}
void dope() { wtf.clear(); }
};
int main(){
(new test())->dope();
return 0;
}
而且我不知道为什么。当我删除易失性时,它再次工作。那么,为什么波动很大?
我认为真正的问题是你为什么要'volatile'std :: vector? – jrok
我得到了(用gcc 4.8.1):'error:passing'volatile std :: vector>'as'this'argument'void std :: vector <_Tp, _Alloc> :: clear()[with _Tp = std :: basic_string ; _Alloc = std :: allocator >]'丢弃限定符[-fpermissive]' –
Jarod42
它包含必须由程序每次访问的信息。它是多线程的。 – user2741831