k**n 发帖数: 20 | 1 应该都是基本语法了
第一个,
#include
using std::cout;
using std::endl;
class Foo {};
class Bar{
public:
operator Foo() { //<- 这是什么?重载()不是这样的吧
return Foo(); //还有这个?
}
};
int main (int argc, char * const argv[]) {
...............
...................
}
第二个, preprocessor:
#define pair_type(t,u) struct pair##_t##_u //为什么要_t,_u?( 和pair##t##u 有什么不同?)(好像两种都能run)
#define pair_decl(t,u) pair_type(t,u) { \
t first; \
u second; \
}
pair_decl(int,int); //展开是什么?struct pairintint {int |
k**n 发帖数: 20 | 2 I got the second one. Sorry for my stupidity.
Anyone can help me on the other two?
【在 k**n 的大作中提到】 : 应该都是基本语法了 : 第一个, : #include : using std::cout; : using std::endl; : class Foo {}; : class Bar{ : public: : operator Foo() { //<- 这是什么?重载()不是这样的吧 : return Foo(); //还有这个?
|
S*****n 发帖数: 227 | 3
C++ conversion function.. google or whatever to find the meaning.
【在 k**n 的大作中提到】 : 应该都是基本语法了 : 第一个, : #include : using std::cout; : using std::endl; : class Foo {}; : class Bar{ : public: : operator Foo() { //<- 这是什么?重载()不是这样的吧 : return Foo(); //还有这个?
|
c********e 发帖数: 383 | 4 the key that you could have that looks-like recursive definition is the
keyword "static"
it is semantically correct, but as to if the current C++ standards allows
it wait for the response from thrust.
【在 k**n 的大作中提到】 : 应该都是基本语法了 : 第一个, : #include : using std::cout; : using std::endl; : class Foo {}; : class Bar{ : public: : operator Foo() { //<- 这是什么?重载()不是这样的吧 : return Foo(); //还有这个?
|
t****t 发帖数: 6806 | 5 hmm?合法的吧.
【在 c********e 的大作中提到】 : the key that you could have that looks-like recursive definition is the : keyword "static" : it is semantically correct, but as to if the current C++ standards allows : it wait for the response from thrust.
|
c********e 发帖数: 383 | 6 ft...u should say like:
quoting from the standard:
"........"
it is legal/illegal
【在 t****t 的大作中提到】 : hmm?合法的吧.
|
t****t 发帖数: 6806 | 7 说得不是很明确,所以我没 quote
那就来一下
1.class不能包含自己[9.2,c8].
2.static data member应该是以前定义过的类型[9.2,c8]
3.[9.4.2]
2 The declaration of a static data member in its class definition is not
a definition and may be of an incomplete type other than cv-qualified
void. ...
【在 c********e 的大作中提到】 : ft...u should say like: : quoting from the standard: : "........" : it is legal/illegal
|
c********e 发帖数: 383 | 8
~~~~~~~~~~ isnt this clear enough?
【在 t****t 的大作中提到】 : 说得不是很明确,所以我没 quote : 那就来一下 : 1.class不能包含自己[9.2,c8]. : 2.static data member应该是以前定义过的类型[9.2,c8] : 3.[9.4.2] : 2 The declaration of a static data member in its class definition is not : a definition and may be of an incomplete type other than cv-qualified : void. ...
|
k**n 发帖数: 20 | 9 I see. Thank you all.
crystalike and thrust, what's [9.*] for? is it the document of ANSI c++?
where to find it? |
t****t 发帖数: 6806 | 10 iso c++.
i use a draft, but it's close enough. draft should be free online.
【在 k**n 的大作中提到】 : I see. Thank you all. : crystalike and thrust, what's [9.*] for? is it the document of ANSI c++? : where to find it?
|