在C ++中通过引用传递?

时间:2015-09-11 18:35:30

标签: c++

我无法让一个类识别出另一个类存在。我相信这是通过参考,但我不确定。

class A{
public: 
A(B b);
};

class B{
public:
B(A a);
};

class B中,B的构造函数会识别出我正在通过A,但在class A我会继续

  

无法解析类型'B'

错误。

1 个答案:

答案 0 :(得分:3)

这与"传递",通过引用或其他方式无关。

问题是当您尝试在课程 Private Sub Test() Dim a = True Dim b = False Dim c = True Dim d = True Dim printout As String = "" If a Then printout = "a is true" Else If b Then If c Then printout = "b and c are true" else printout="b is true and c is not true" End If If d and c Then printout = "b and c and d are true" elseif d=true and c=false then printout = "b and d are true , c is not true" elseif c=true and d=false then printout = "b and c is true ,d is not true" else printout = "b is true ,c and d are not true" End If End If End If Console.WriteLine(printout) End Sub 中使用课程时,尚未声明课程B

您需要forward declarationA

B
相关问题