gcc compiler error in copy ctor: "expected primary-expression before > token"
Here's my code. It compiles in VS2005 but not in gcc. Any ideas
temp开发者_如何学运维late<class T>
Derived<T>::Derived(const Derived<T>& in)
{
Base<T>::Base<T>(in); //ERROR here
}
"expected primary-expression before > token"
You can't call constructors explicitly like that (if VS2005 allows you to, it's a compiler-specific extension). The correct way to pass an argument to your parent class's constructor is:
template<class T>
Derived<T>::Derived(const Derived<T>& in)
: Base<T>(in)
{
}
精彩评论