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
|