[Quote=引用 27 楼 jieao111 的回复:]
从外覆类上调用,而不必实例化外覆类的对象,,谁能给个例子
[/Quote]
比如在Java中,如果类B是类A的公有静态内部类,即:
public class A {
public static class B {}
}
那么你可以直接:
A.B b = new A.B();
但如果B不是静态的内部类,就不能这么做了,而必需:
A a = new A();
A.B b = a.new B();
在这一点上,g++比VC靠谱,因为C++标准(ISO-IEC-14882(2003))说得很明确:
7.1.1.4
The static specifier can be applied only to names of objects and functions and to anonymous unions (9.5). There can be no static function declarations within a block, nor any static function parameters. A static specifier used in the declaration of an object declares the object to have static storage duration (3.7.1). A static specifier can be used in declarations of class members;
9.4.1
A data or function member of a class may be declared static in a class definition, in which case it is a static member of the class.