在 C 中声明 == 在 C 中定义++?
可能的重复:
定义和声明之间有什么区别?< /a>
在 C 中声明等于在 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++
Possible Duplicate:
What is the difference between a definition and a declaration?
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++
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
不。
对于函数,我见过“declare”仅用于编写标题,而“define”用于编写主体。
然而,这都是自然语言。 C 示例中的“声明”对于 C 和 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++.
在 C 中,声明意味着告诉编译器它存在,而定义则是为其分配实际值。
我看不出为什么这在 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