【发布时间】:2018-04-06 11:55:20
【问题描述】:
传递给 function1 和 function2 的内容有什么区别?
struct Node
{
int data;
struct Node *next;
};
void function1(struct Node *start)
{
// ...
}
void function2(Node *start)
{
// ...
}
【问题讨论】:
-
无。你是从什么来源学习 C++ 的?
-
@melpomene 不准确。如果名为
Node的对象在范围内,第一个将起作用,第二个将无法编译。如果尚未声明,第一个也将在外部范围内声明struct Node。 -
@melpomene 有区别,这个叫Elaborated type specifier
-
"struct Node" 是 C-ism。在 C++ 中,不需要“结构”。
-
@Quentin Point,但在提供的代码中定义了
struct Node,并且没有其他对象。
标签: c++ struct scope declaration