开发者

gcc compiler error in copy ctor: "expected primary-expression before > token"

开发者 https://www.devze.com 2022-12-30 20:05 出处:网络
Here\'s my code. It compiles in VS2005 but not in gcc. Any ideas temp开发者_如何学运维late<class T>

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

精彩评论

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