g++ -c on the following code fragment:
void f ( void ) {
class Local {
static int j ;
} ;
}
gives the following errors:
static-member-in-local-class.cpp: In function ‘void f()’:
static-member-in-local-class.cpp:3: error: local class ‘class
f()::Local’ shall not have static data member ‘int f()::Local::j’
static-member-in-local-class.cpp:3: error: field ‘f()::Local::j’ in
local class cannot be static
I understand that local classes cannot have static members because it is
not possible to describe the data member at file scope in order to
define it.
But what is the difference between "local class shall not have static
data member" and "field in local class cannot be static"?
Thanks as always.
Shriramana Sharma.
-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html