C ++模板类指针多态 [英] C++ template class pointer polymorphism

查看:64
本文介绍了C ++模板类指针多态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好!


我有一个继承自非模板基类的模板类。它具有基类没有的功能(因为基类需要模板参数)。但是我不知道如何在这种情况下通过基类指针正确使用多态。

示例:

Hello!

I have a template class which inherits from a non-template base class. It has functions the base class doesn''t have (because the base class would need the template argument). But I don''t know how to properly use polymorphism though a base class pointer in this case.
Example:

展开 | 选择 | Wrap | 行号

推荐答案

好的我修改了代码以便编译:
OK I fixed the code so it would compile :
< span class =codeLinkonclick =Blur(this,this.parentNode.parentNode,getChildren(this),true);>展开 | 选择 | Wrap | 行号


谢谢!它工作(除了注释掉#include" BaseNonTemplateClass.h",但无论如何)。但实际上我遇到了另一个问题。我发布的代码是一个简化的测试项目,用于简化具有相同问题的更大项目。我希望我可以转移解决方案,但我不知道如何解决主要问题。我可以发布一些代码,但这将是更具体和更多的代码。
Thanks! It worked (beside the commented out #include "BaseNonTemplateClass.h", but anyway). But actually I ran into another problem. The code I posted was a simplified test project, to simplify a bigger project with the same problem. I hoped I could just transfer the solution, but I don''t know how to solve the main problem. I could post some code, but this is going to be more specific and more code.


这是我的实际项目的重要部分,我有一些类似的结构,我得到了编译器错误。 InputBaseClass.h:
Here are the important parts of my actual project, on which I have some similar structures, and I got a compiler error. InputBaseClass.h:
展开 | 选择 < span class =codeDivider> | Wrap | 行号


这篇关于C ++模板类指针多态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆