[英]What is the difference between "struct *Stack stack" and "struct Stack* stack"?
当我在编写struct *Stack stack
时编写代码时,代码不起作用,当我像struct Stack* stack
代码一样编写它时,有人能告诉我这两个代码之间的区别吗?
While writing a code when I am writing struct *Stack stack then code is not working
在编写 struct *Stack 堆栈时编写代码时,代码不起作用
This is because struct *Stack stack
is not correct syntax.这是因为
struct *Stack stack
语法不正确。 This would imply a pointer named Stack stack
, which is not a valid name, pointing to a struct
, which is not valid in c or c++ , as you have to indicate what type of struct
your pointer will be pointing to.这意味着一个名为
Stack stack
的指针,它不是一个有效的名称,指向一个struct
,它在c或c++ 中无效,因为您必须指出您的指针将指向什么类型的struct
。 The word struct
is not standalone. struct
这个词不是独立的。
when I am writing it like struct Stack* stack code is working
当我写它就像 struct Stack* 堆栈代码正在工作时
On the other hand, the declaration :另一方面,声明:
struct Stack* stack;
implies a pointer named stack
which points to a struct Stack
(which you have defined somewhere).暗示了一个名为
stack
的指针,它指向一个struct Stack
(你已经在某处定义了它)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.