由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - Help: who has gcc 4.0 or higher
相关主题
template 类的继承问题模板对象能不能作为成员变量使用
小问题问一个C++的问题
请教各路C++大神 为什么f(3) 输出是 'dd'这个是什么设计模式?
thrust help ~~~question on template and inheritance?
私有成员不能用类成员函数修改?问行C++代码
boost::function 的 syntax 问题请教C++问题
C++里get array size的问题 (转载)C++ Q98: Call member function in virtual function (转载)
一个关于C++ template和overload的问题一个C++ template的问题
相关话题的讨论汇总
话题: template话题: upper话题: base话题: class话题: int
进入Programming版参与讨论
1 (共1页)
c********e
发帖数: 383
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 class Derived>
class Base
{
public:
t****t
发帖数: 6806
2
不行
1.C: In constructor 'Upper::Upper(int)':
1.C:46: error: type/value mismatch at argument 1 in template parameter list
for 'template class Derived> class Base'
1.C:46: error: expected a class template, got 'Upper'

【在 c********e 的大作中提到】
: plz compile below code for me if you could, thx.
: #include
: /*
: //normal one works
: template
: class Base
: {
: public:
: Base (int i) : i_ (i) {}
: private:

t****t
发帖数: 6806
3
原因是这样
14.6.1
1 Within the scope of a class template, when the name of the template is
neither qualified nor followed by <, it is equivalent to the name of
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 class Derived> class Base'
: 1.C:46: error: expected a class template, got 'Upper'

c********e
发帖数: 383
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 <, it is equivalent to the name of
: 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

c********e
发帖数: 383
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.

r****t
发帖数: 10904
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 <, it is equivalent to the name of
: 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

1 (共1页)
进入Programming版参与讨论
相关主题
一个C++ template的问题私有成员不能用类成员函数修改?
[合集] 关于template和inheritance的问题请教boost::function 的 syntax 问题
C++ virtual function 定义在 derived class 会怎么样?C++里get array size的问题 (转载)
a simple question for C++ class一个关于C++ template和overload的问题
template 类的继承问题模板对象能不能作为成员变量使用
小问题问一个C++的问题
请教各路C++大神 为什么f(3) 输出是 'dd'这个是什么设计模式?
thrust help ~~~question on template and inheritance?
相关话题的讨论汇总
话题: template话题: upper话题: base话题: class话题: int