我无法让一个类识别出另一个类存在。我相信这是通过参考,但我不确定。
class A{
public:
A(B b);
};
class B{
public:
B(A a);
};
在class B
中,B
的构造函数会识别出我正在通过A
,但在class A
我会继续
无法解析类型'B'
错误。
答案 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 declaration班A
:
B