English(beta)
hfyb的Blog 页面正在加载中 .....

类中的静态成员与非静态成员的区别

Class myclass()
{
     int a=10;
     static int b=20;
}
Class test()
{
     myclass A=new myclass();
     A.a=10;           //正确
     A.b=20;           //不能通过对象访问类中的静态成员
     myclass.a=10;  //不能通过类访问非静态成员
     myclass.b=20;  //正确
}

通过这个简单的事例,我们就可以很清楚的了解类中的静态成员与非静态成员的区别。

posted on 2006-11-28 14:02  hfyb  阅读(1011)  评论(0编辑  收藏  举报

导航