C++ 结构名称中的指针
Pointer in c++ struct name
我遇到了这段用于 c++ 链表实现的代码。
struct node
{
int info;
struct node *next;
}*start;
拥有*start
而不仅仅是start
意味着什么?
以后这样使用会怎样?s
是什么意思,它没有在函数中的其他任何地方引用?
struct node *temp, *s;
temp = new(struct node);
片段
struct node
{
int info;
struct node *next;
}*start;
相当于
struct node
{
int info;
struct node *next;
};
struct node *start;
因此,在第一个片段中,您可以在一个语句中定义一个名为 node
的结构和一个名为 start
的 struct node *
类型的变量。就这样。
请注意,在C++中(与 C 不同(,您也可以编写
struct node
{
int info;
node *next;
};
node *start;
即,在定义类型为 struct node
的变量时,您可以省略 struct
-关键字。
相关文章:
- 如何在 C# 中映射双 C 结构指针?
- 指针或结构的矢量
- MSVC将仅移动结构参数解释为指针
- 如何访问指针结构的成员变量?
- 如何将变量从变量传递到指针结构对象
- 如何在函数中检索指针结构
- C :变量的点地址至指针结构成员的地址
- C++指针结构不会被删除
- 初始化指针结构 - 内存中的外观
- C++指针结构和多线程
- c++中指针结构的运算符重载
- 为什么我不能转发声明指针结构?
- C# 如何定义新的指针结构
- 如何处理大型指针结构
- 我怎么能写一个函数的定义在模板类中声明返回指针结构对象
- 我如何编程指针结构或类变量在c++
- 具有指针结构的类所需的析构函数
- 为什么在非指针结构上进行类型转换会出现语法错误
- 语法:做binary_search (STL)排序向量的指针结构
- /a.检测到Glibc.out: munmap_chunk():无效指针- c++结构体的动态数组