Usage
| (since C++11) |
- If a function or a variable exists in scope with the name identical to the name of a non-union class type,
structcan be prepended to the name for disambiguation, resulting in an elaborated type specifier.
Example
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
}See also
| (since C++11) |
Content from this page on cppreference.com, licensed under CC-BY-SA 3.0 and GFDL. Modified: restyled, site navigation removed, code windows added. Offline snapshot of 9 February 2025.