我有这样的结构
struct structure
{
BaseObject &A; //BaseObject has a function declared as virtual
};
在运行时,我动态地将一个对象分配给 &A
structure *s = new structure;
DerivedObjectB *B = new DerivedObjectB(); //Derived class overloads the virtual function
s->A = *B; //s is a pointer of the structure. S has been initialized
我可以编译此代码,但在运行时出现段错误。我有一个限制,我不能使用指针。这不是家庭作业。由于构建 SSA 的问题,我用作反向编译器的编译器限制使用指针