我有两个大班,在两个单独的单位中定义。这两个班级的成员都与另一个成员相关联。前向声明没有用,因为类不在同一类型块中。
除了合并这两个外,还有其他解决方案吗?
1单元:
> db.so.ensureIndex( { parentID: 1 , slugID: 1 } , { sparse: true , unique: true } )
> db.so.insert( { parentID: "id1" } )
> db.so.insert( { parentID: "id1" } )
> E11000 duplicate key error index: test.so.$parentID_1_slugID_1 dup key: { : "id1", : null }
UNIT2:
uses
Unit2;
type
TclassA = class
Method1: TClassB;
end;
答案 0 :(得分:1)
除了合并这两个外,还有其他解决方案吗?
没有。这是一个牢不可破的规则。如果两种类型相互引用,并且两者都需要在接口部分声明,则必须在同一单元中定义它们。