由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - c++ template question:
相关主题
typedef 的一个问题STL感觉实在太变态了
boost::function 的 syntax 问题这两个地方是否需要typename?
一个partial specialization的问题有段c++代码看不懂
C++ question about template typedef又问几个c语言编程的题目
C++里get array size的问题 (转载)问个 enum{}的问题 谢谢 (转载)
如何 define/initialize static data member of a class templ{C语言}请教如何通过变量访问结构体内的各个属性
C++ 菜鸟问一个关于template 的问题。a c++ question
一个C++ template的问题如何使用这个template?
相关话题的讨论汇总
话题: template话题: isclasst话题: typename话题: yes话题: two
进入Programming版参与讨论
1 (共1页)
F*******i
发帖数: 190
1
trying a sample code from template complete:
template
class IsClassT {
private:
typedef char One;
typedef struct { char a[2]; } Two;
template static One test(int C::*);
template static Two test((B!DB);
public:
enum { Yes = sizeof(IsClassT::test(0)) == 1 }; //ERROR LINE
enum { No = !Yes };
};
It is supposed to work from the book, however, the g++ complains as:
line 21: error: expected primary-expression before '>' token
do not
b********n
发帖数: 609
2
加括号试试看。

【在 F*******i 的大作中提到】
: trying a sample code from template complete:
: template
: class IsClassT {
: private:
: typedef char One;
: typedef struct { char a[2]; } Two;
: template static One test(int C::*);
: template static Two test((B!DB);
: public:
: enum { Yes = sizeof(IsClassT::test(0)) == 1 }; //ERROR LINE

r****r
发帖数: 115
3
菜啊,看不懂这个template

【在 F*******i 的大作中提到】
: trying a sample code from template complete:
: template
: class IsClassT {
: private:
: typedef char One;
: typedef struct { char a[2]; } Two;
: template static One test(int C::*);
: template static Two test((B!DB);
: public:
: enum { Yes = sizeof(IsClassT::test(0)) == 1 }; //ERROR LINE

D*******a
发帖数: 3688
4

不懂template,不过这行是不是少了括号?

【在 F*******i 的大作中提到】
: trying a sample code from template complete:
: template
: class IsClassT {
: private:
: typedef char One;
: typedef struct { char a[2]; } Two;
: template static One test(int C::*);
: template static Two test((B!DB);
: public:
: enum { Yes = sizeof(IsClassT::test(0)) == 1 }; //ERROR LINE

r****r
发帖数: 115
5

这行啥意思啊?一个右括号?

【在 F*******i 的大作中提到】
: trying a sample code from template complete:
: template
: class IsClassT {
: private:
: typedef char One;
: typedef struct { char a[2]; } Two;
: template static One test(int C::*);
: template static Two test((B!DB);
: public:
: enum { Yes = sizeof(IsClassT::test(0)) == 1 }; //ERROR LINE

r****r
发帖数: 115
6
peng自己一下

【在 r****r 的大作中提到】
:
: 这行啥意思啊?一个右括号?

c***d
发帖数: 996
7
change IsClassT:: to IsClassT::template .

【在 F*******i 的大作中提到】
: trying a sample code from template complete:
: template
: class IsClassT {
: private:
: typedef char One;
: typedef struct { char a[2]; } Two;
: template static One test(int C::*);
: template static Two test((B!DB);
: public:
: enum { Yes = sizeof(IsClassT::test(0)) == 1 }; //ERROR LINE

1 (共1页)
进入Programming版参与讨论
相关主题
如何使用这个template?C++里get array size的问题 (转载)
Any difference between class and typename identifier?如何 define/initialize static data member of a class templ
[菜鸟问题]类模板问题C++ 菜鸟问一个关于template 的问题。
文一个简单的c++一个C++ template的问题
typedef 的一个问题STL感觉实在太变态了
boost::function 的 syntax 问题这两个地方是否需要typename?
一个partial specialization的问题有段c++代码看不懂
C++ question about template typedef又问几个c语言编程的题目
相关话题的讨论汇总
话题: template话题: isclasst话题: typename话题: yes话题: two