【发布时间】:2015-03-26 10:36:09
【问题描述】:
我正在尝试在 Raspberry Pi 上使用 shared_ptrs 编译代码:
#include <iostream>
using namespace std;
int main(int argc, char* argv[]){
shared_ptr<string> message1(new string("Hello Raspberry Pi C++11"));
cout << *message1 <<endl;
return 0;
}
我收到以下错误:
test.cpp: In function 'int main(int, char**)': test.cpp:4:4: error: 'shared_ptr' was not declared in this scope
shared_ptr<string> message1(new string("Hello Raspberry Pi C++11"));
^ test.cpp:4:21: error: expected primary-expression before '>' token
shared_ptr<string> message1(new string("Hello Raspberry Pi C++11"));
^ test.cpp:4:70: error: 'message1' was not declared in this scope
shared_ptr<string> message1(new string("Hello Raspberry Pi C++11"));
我正在用这个命令编译:g++ -std=c++11 -o test test.cpp
G++版本为g++ (Raspbian 4.8.2-21~rpi3rpi1) 4.8.2
请帮忙。
【问题讨论】:
标签: c++11 compiler-errors shared-ptr