开发者

Declare in C == define in C++? [duplicate]

This question already has answers here: Closed 12 years ago.

Possible Duplicate:

What is the difference between a definition and a declaration? 开发者_JS百科

Is it correct that to declare in C is equal to define in C++?

int a;     /* to declare variabel a in C */
int b = 2; /* to declare and initialize in C */


int c;     // to define in C++ 
int d = 4; // to define and initialize in C++ 


No.

For functions, I've seen "declare" being used for just writing the header, whereas "define" was used for writing the body.

However, it's all natural language. "declare" as in you C example seems correct for both C and C++.


In C, declaring means to tell the compiler it exists whereas defining is assigning an actual value to it.

I see no reason why this would be different in C++


yes it should be

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜