Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
171 views
in Technique[技术] by (71.8m points)

C++ Inheritance via dominance warning

I'm trying to implement a rather large object that implements many interfaces. Some of these interfaces are pure virtual. I may have a problem in diamond inheritance. Visual Studio is reporting a warning of C4250 ('class1' : inherits 'class2::member' via dominance). First of all these classes are inherited virtually as it should be. The following is the partial class design that causes this problem.

A        B        C
       /       /
      /       /
    AB       BC 
    |         |
    |        BC2
    |         |
             D: Implementation of B, C, BC, BC2
            /
        Big

In this entire tree only D implements virtual methods, there is no other definition of the method in question. And all virtual methods of B is listed in warnings. If important, D is a complete class.

I read this happens with Boost serialization and it is safe to disregard the warning.

Is this method I am trying to achieve valid? Is it safe to disregard this warning?

Note 1: This is not a duplicate of Visual Studio Compiler warning C4250 ('class1' : inherits 'class2::member' via dominance), I have tried the solution proposed there.

Note 2: I can also send class diagram but its a little more complicated than this.

EDIT: Full warning is as follows:

warning C4250: 'gge::resource::ImageResource' : inherits 
'gge::graphics::ImageTexture::gge::graphics::ImageTexture::drawin' 
via dominance

gge::resource::ImageResource is Big in the drawing, gge::graphics::ImageTexture is D, drawin is one of the six methods I get warning for.

question from:https://stackoverflow.com/questions/6864550/c-inheritance-via-dominance-warning

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Everything is absolutely valid. A compiler is allowed to warn about valid code, no problem here. You can try silencing the warning with a using declaration. If this doesn't work (probably due to an MSVC bug), silence it with a pragma.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...