polymorphic C++ references

前端 未结 7 1075
闹比i
闹比i 2020-12-09 09:07

I was wondering how you can do polymorphism with references, as opposed to pointers.

To clarify, see the following minimal example:

cl         


        
7条回答
  •  孤城傲影
    2020-12-09 09:44

    This is indeed a bit odd. If you want a member-variable of type A1 (rather than a reference), why not just rearrange your code so that the definition of A1 appears before the definition of B?

提交回复
热议问题