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