c++ - 包括 tr1::shared_ptr

标签 c++ gcc g++

我已经包括了#include </usr/include/c++/4.4.3/tr1/shared_ptr.h>在我的类(class)文件中, 当我尝试编译我的类时,出现以下错误:

> In file included from account.h:16:0:
/usr/include/c++/4.4.3/tr1/shared_ptr.h:61:46: error: '_Lock_policy' has not been declared
/usr/include/c++/4.4.3/tr1/shared_ptr.h:63:30: error: expected template-name before '<' token
/usr/include/c++/4.4.3/tr1/shared_ptr.h:63:30: error: expected '{' before '<' token
/usr/include/c++/4.4.3/tr1/shared_ptr.h:63:30: error: expected unqualified-id before '<' token
/usr/include/c++/4.4.3/tr1/shared_ptr.h:89:12: error: '_Lock_policy' has not been declared
/usr/include/c++/4.4.3/tr1/shared_ptr.h:89:31: error: '__default_lock_policy' was not declared in this scope
/usr/include/c++/4.4.3/tr1/shared_ptr.h:100:12: error: '_Lock_policy' has not been declared
/usr/include/c++/4.4.3/tr1/shared_ptr.h:100:31: error: '__default_lock_policy' was not declared in this scope
/usr/include/c++/4.4.3/tr1/shared_ptr.h:209:7: error: '_Sp_counted_base' does not name a type
/usr/include/c++/4.4.3/tr1/shared_ptr.h: In constructor 'std::tr1::__shared_count<_Lp>::__shared_count()':

有谁知道究竟是什么导致了这个错误?

最佳答案

我已经添加了 #include <tr1/memory>并解决了问题。

关于c++ - 包括 tr1::shared_ptr,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5170670/

相关文章:

c++ - Winsock 中 SOCKET 对象的范围是什么?

c++ - 如何将 MongoDB 与 Qt C++ 连接起来?

c++ - 合并排序只返回大小为 2 的幂的 vector

gcc - 在GCC中链接包含文件

c++ - winsock 服务器故障排除

c++ - 了解在 C++ 中打印链接列表的错误

c++ - 函数指针指向什么?

c++ - g++ 既是 C++ 编译器又是链接器?

gcc -print-prog-name=???没有像我预期的那样工作

c++ - C 库链接到 C++