开发者

Why this code does not compile using MS compiler?

开发者 https://www.devze.com 2023-04-08 07:07 出处:网络
This code does compile using the GNU gcc compiler while doesn\'t if using the Visual Studio 2008 one.

This code does compile using the GNU gcc compiler while doesn't if using the Visual Studio 2008 one.

the error sas: "error C2143: syntax error: missing ';' before '*'

Arbol::Nodo* is a pointer to the class inside Arbol that works ok if compiling using codeblocks + gnu gcc compiler.

template <开发者_如何转开发class T>
Arbol<T>::Nodo<T>* Arbol<T>::Alta(Nodo<T>* &nodo,const T d) /////this line is highlited
{
     return nodo;
}

It's weird, If I take out that code and compile again, it jumps three functions below it and throws the same error with this function

 template<class T>
 Arbol<T>::Nodo<T>* Arbol<T>::BuscarDevolver(const T t)
 {
     Nodo<T>* nodo = new Nodo<T>;
     return nodo;
 }


Add typename:

template <class T>
typename Arbol<T>::Nodo<T>* Arbol<T>::Alta(Nodo<T>* &nodo,const T d) /////this line is highlited
{
     return nodo;
}

You need to mark qualified names that are types explicitly within a template.

0

精彩评论

暂无评论...
验证码 换一张
取 消