How to simulate virtuality for method template

后端 未结 5 1046
忘了有多久
忘了有多久 2021-01-19 14:08

I have a class hierarchy where I want to introduce a method template that would behave like if it was virtual. For example a simple hierarchy:

class A {
  vi         


        
5条回答
  •  深忆病人
    2021-01-19 14:39

    I think the only solution is the http://en.wikipedia.org/wiki/Visitor_pattern

    See this topic: How to achieve "virtual template function" in C++

提交回复
热议问题