Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

qualified names in C++ class declaration

According to this page, the class name can be "optionally qualified". Thus, I expect the following code to compile:

struct ::globalSt {};

In MSVC 2013u4, I get an error:

Error 1 error C2039: 'globalSt' : is not a member of '`global namespace''

Am I misinterpreting the reference or is that a MSVC bug?

like image 729
Hector Avatar asked Dec 01 '25 06:12

Hector


1 Answers

If you define a class with a qualified name, the name must have been previously declared. [class]/11

If a class-head-name contains a nested-name-specifier, the class-specifier shall refer to a class that was previously declared directly in the class or namespace to which the nested-name-specifier refers, or in an element of the inline namespace set (7.3.1) of that namespace (i.e., not merely inherited or introduced by a using-declaration), and the class-specifier shall appear in a namespace enclosing the previous declaration. In such cases, the nested-name-specifier of the class-head-name of the definition shall not begin with a decltype-specifier.

like image 170
Brian Bi Avatar answered Dec 03 '25 21:12

Brian Bi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!