开发者

Why the bullseye code coverage doesn't trace a pure virtual function of inherited class?

I met a problem about the Bullseye code coverage. It's a tracing ability of the program. The following code is not traced.

class A
{
public:
    virtual void func() = 0;
};

class B
{
public:
    virtual void func()
    {
         std::cout << "Am I traced?" << std::endl;
    }
};

void main()
{
    A *pa = new B;
   开发者_如何学运维 pa->func();
}

I guess that Bullseye may not trace pure virtual function. If there are someone who has a knowledge about the program, please give me some advice.


You have 2 errors, in the given program:

void func() = 0;

should be,

virtual void func() = 0;

And,

class *pa = new B;

should be,

class B *pa = new B;  // `class` keyword not needed

Also, note that A and B are not related (no inheritance).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜