【发布时间】:2016-05-21 14:48:08
【问题描述】:
以下代码有什么问题。 我收到编译错误。 我也尝试过 B 类的前向声明。但未能成功。
Test.cpp
#include <memory>
#include <iostream>
namespace api
{
class A
{
public:
typedef std::shared_ptr<A> APtr;
APtr get_a_ptr();
B::BPtr get_b_ptr();
};
class B
{
public:
typedef std::shared_ptr<B> BPtr;
BPtr get_b_ptr();
A::APtr get_a_ptr();
};
}
int main(int argc, char **argv)
{
return 0;
}
【问题讨论】:
标签: c++ class oop c++11 forward-declaration