未调用c ++派生函数

时间:2012-03-11 23:04:34

标签: c++ visual-c++ inheritance dll polymorphism

很抱歉所有的混淆,我错误地在类继承中输入了:: :,并且错过了关键字public。它始终是:。再次感谢所有帮助。

首先,标题可能过于笼统,但我不知道在这里描述问题的更好方法。

我有什么,

class __declspec(dllimport) Foo1:public Foo
{
  virtual BOOLEAN bar(Arg *arg);
}

class __declspec(dllimport) Foo2:public Foo1
{   
    virtual BOOLEAN bar(Arg *arg);  //newly added
}

这两个函数都已实现,我在Foo2下有一个函数

BOOLEAN Foo2::dosomething(Arg* arg)  //Question 1, should the position of * matter here?
{
  bar(arg);
}

但是这仍然会调用Foo1::bar而不是Foo2::bar。我仔细检查了签名,没有问题。所以我做了一些实验,

  1. 使用PE Explorer比较Foo1Foo2 dll中导出的受损函数名称,结果为

    ?bar@Foo1@@MAEEPAVARG@@@Z
    ?bar@Foo2@@UAEEPAVARG@@@Z
    问题2,信中是否有差异?

  2. bar删除Foo1,然后运行,出现错误并说,

    The procedure engry point ?bar@Foo1@@MAEEPAVARG@@@Z could not be located in the dynamic link library libFoo1.dll

  3. 我在这里不明白的是,呼叫在Foo2下,但仍在尝试查找Foo1的功能。此外,在Foo1之前和Foo2之后存在多个级别的继承,因此我不确定我是否缺少在函数派生使用或dll导出方面重要的内容,也没有专家。< / p>

    希望我能就我应该制定的方向或可能的原因得到一些建议。

    不确定我是否清楚地描述了问题,如有必要,请随时修改。

    谢谢!

0 个答案:

没有答案