3
我想玩弄C++ 11的新功能,即使用Smart Pointers
。我发现了一个exampleg ++(Ubuntu的/ Linaro的4.7.2-2ubuntu1)4.7.2这里:Cplusplus11-Smart-Pointers:激活智能指针?
#include <memory>
int main() {
std::shared_ptr<int> sptr1(new int);
}
当我尝试一下就是一切,我得到:
In function ‘int main()’:|
error: ‘shared_ptr’ was not declared in this scope|
error: expected primary-expression before ‘int’|
error: expected ‘;’ before ‘int’|
这是我的G ++版本:
g++ (Ubuntu/Linaro 4.7.2-2ubuntu1) 4.7.2
我必须首先“激活”C++ 11吗?
您需要使用'-std = C++ 11'编译器标志。 – juanchopanza 2013-05-06 18:25:12
我可以在哪里输入该标志?我使用Code :: Blocks 10.05。 – user1170330 2013-05-06 18:29:56
设置>编译器>编译器设置>其他选项 – Morwenn 2013-05-06 18:39:35