开发者

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)
{
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜