命名空间
变体
操作

C++ 关键字: struct

来自 cppreference.cn
< cpp‎ | 关键字
 
 
C++ 语言
 
 

[编辑] 用法

(C++11 起)
  • 如果在作用域中存在与非联合类类型名称相同的函数或变量,可以在名称前加上 struct 以消除歧义,从而形成阐明类型说明符

[编辑] 示例

struct Foo; // forward declaration of a struct
 
struct Bar  // definition of a struct
{
    Bar(int i) : i(i + i) {}
 
    int i;
};
 
enum struct Pub // scoped enum, since C++11
{
    b, d, p, q,
};
 
int main()
{
    Bar Bar(1);
    struct Bar Bar2(2); // elaborated type
}

[编辑] 参阅

(C++11 起)