1

我目前正在尝试做作业,并且我正在尝试首先编译我的东西(.h 文件中的类头,以及 .inl 文件中的空定义(我正在使用类型名模板) )。

我收到此错误:

error: expected constructor, destructor, or type conversion before ‘*’ token

这是我的 .h 文件:http: //ideone.com/dm3Bp

这是我的 .inl 文件:http: //ideone.com/5FBep

我正在尝试在 .inl 文件的末尾创建一个节点(在这些文件中称为 Noeud)。显然,我不能从 E 型数据数组中获取值...

错误就在方法定义之前:

Noeud * Arbre<E>::_auxPereSym(E *tabS, int debut, int fin, E **ptr, int &card) throw (std::bad_alloc)

我在其他线程中读到返回类型应该是 Arbre< E >::Noeud 因为 Noeud 是我的类 Arbre 的嵌套结构......但不幸的是,我无法更改头文件......

有什么想法吗?

感谢您的时间和帮助。

注意:如果需要翻译,请告诉我,这是法语作业。

4

1 回答 1

3

尝试在 .inl 文件(而不是您所关心的头文件)中定义时符合条件。

需要在适当的范围内适当地查找返回类型。

提前大脑编译代码

template<typename E>
typename Arbre<E>::Noeud * Arbre<E>::_auxPereSym(E *tabS, int debut, int fin, E **ptr, int &card) throw (std::bad_alloc)

编辑2:

将成员函数中的 return 语句更改为:

return new typename Arbre<E>::Noeud(tabS[0]);
于 2010-11-17T02:35:05.607 回答