之前的预期模板名称?<? token.Template类继承和虚方法 [英] Expected template-name before ?<? token.Template class inheritance and virtual method
问题描述
大家好,
我在Windows-MS VS2005上编译的C ++源代码没有任何问题。我试图在Linux gcc版本4.1.2(Ubuntu 4.1.2-0ubuntu4)中编译它,我遇到了以下编译器错误:
错误:之前的模板名称是什么? < ;?令牌
错误:预期`{''之前?<?令牌
错误:预期的不合格身份?之前?<?令牌
(错误指向包含类myMarchingSurface3D的行:派生类中的公共CMarchingSurface3D< U>)
我查看了其他线程,似乎模板类的继承给出了一些可移植性问题。我在这里附上代码:
class myMarchingSurface3D:public CMarchingSurface3D< U> {
public:
[... othe rmethods]
您需要将此类声明为模板以支持从CMarchingSurface3D< U>继承。否则,编译器认为U是真实类型:
展开 | 选择 | Wrap | 行号
您需要将此类声明为模板以支持从CMarchingSurface3D< U>继承。否则,编译器认为U是真实类型:
展开 | 选择 | Wrap | 行号
否。我使用Visual Studio.NET 2005进行编译。我对gcc知之甚少。我假设你正在编译g ++以获得C ++编译器?
Hi all,
I have C++ source code that compiles on windows-MS VS2005 without any problem. I am trying to compile it in Linux gcc version 4.1.2 (Ubuntu 4.1.2-0ubuntu4) and I ran into the following compiler error:
error: expected template-name before ?<? token
error: expected `{'' before ?<? token
error: expected unqualified-id before ?<? token
(the error points to the line containing class myMarchingSurface3D:public CMarchingSurface3D<U> in the derived class)
I have looked in other threads and it seems inheritance with template classes gives some portability problems. I attach the code here:
Expand|Select|Wrap|Line Numbers解决方案class myMarchingSurface3D:public CMarchingSurface3D<U>{
public:
[...othe rmethods]You need to declare this class as a template to support inheriting from CMarchingSurface3D<U>. Otherwise, the compiler thinks U is a real type:
Expand|Select|Wrap|Line Numbers
You need to declare this class as a template to support inheriting from CMarchingSurface3D<U>. Otherwise, the compiler thinks U is a real type:
Expand|Select|Wrap|Line Numbers
No. I got it to compile using Visual Studio.NET 2005. I know very little about gcc. I assume you are compiling as g++ to get the C++ compiler?
这篇关于之前的预期模板名称?<? token.Template类继承和虚方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文登录 关闭
扫码关注1秒登录发送“验证码”获取 | 15天全站免登陆