Redian新闻
>
Help: who has gcc 4.0 or higher
avatar
Help: who has gcc 4.0 or higher# Programming - 葵花宝典
c*e
1
plz compile below code for me if you could, thx.
#include
/*
//normal one works
template
class Base
{
public:
Base (int i) : i_ (i) {}
private:
int i_;
};
template
class Upper : public Base >
{
public:
Upper (int t) : Base > (t) {}
};
int main ()
{
Upper up (1);
}
*/
//template template workes with implicit base mem call
//but can not call explicitly.
template
avatar
t*t
2
不行
1.C: In constructor 'Upper::Upper(int)':
1.C:46: error: type/value mismatch at argument 1 in template parameter list
for 'template
avatar
t*t
3
原因是这样
14.6.1
1 Within the scope of a class template, when the name of the template is
neither qualified nor followed by the template followed by the template-parameters enclosed in <>.
[Example: the constructor for Set can be referred to as Set() or
Set(). ] Other specializations (_temp.expl.spec_) of the class can
be referred to by explicitly qualifying the template name with the
appropriate template-arguments. [Example:
te

【在 t****t 的大作中提到】
: 不行
: 1.C: In constructor 'Upper::Upper(int)':
: 1.C:46: error: type/value mismatch at argument 1 in template parameter list
: for 'template

avatar
c*e
4
ah...thrust u rule.
but can u post the working code? i dont have access to the newer compiler.

【在 t****t 的大作中提到】
: 原因是这样
: 14.6.1
: 1 Within the scope of a class template, when the name of the template is
: neither qualified nor followed by : the template followed by the template-parameters enclosed in <>.
: [Example: the constructor for Set can be referred to as Set() or
: Set(). ] Other specializations (_temp.expl.spec_) of the class can
: be referred to by explicitly qualifying the template name with the
: appropriate template-arguments. [Example:
: te

avatar
c*e
5
nevermind, got it. 3.4 works the same way.
thx

【在 c********e 的大作中提到】
: ah...thrust u rule.
: but can u post the working code? i dont have access to the newer compiler.

avatar
r*t
6
thrust 你这个原因是查的什么资料?有时候有些错误看不懂,你这个资料好像很有用。

【在 t****t 的大作中提到】
: 原因是这样
: 14.6.1
: 1 Within the scope of a class template, when the name of the template is
: neither qualified nor followed by : the template followed by the template-parameters enclosed in <>.
: [Example: the constructor for Set can be referred to as Set() or
: Set(). ] Other specializations (_temp.expl.spec_) of the class can
: be referred to by explicitly qualifying the template name with the
: appropriate template-arguments. [Example:
: te

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。