摘要:
C++的static有两种用法:面向过程程序设计中的static和面向对象程序设计中的static。前者应用于普通变量和函数,不涉及类;后者主要说明static在类中的作用。一、面向过程设计中的static1、静态全局变量在全局变量前,加上关键字static,该变量就被定义成为一个静态全局变量。我们先举一个静态全局变量的例子,如下://Example 1 #include <iostream.h> void fn(); static int n; //定义静态全局变量 void main() { n=20; cout<<n<<endl; fn(); } vo 阅读全文
posted @ 2011-09-17 15:30 weedge 阅读(207) 评论(0) 推荐(0)
浙公网安备 33010602011771号