C++快速入门 第四十三讲:链接和作用域2


1 header.h文件 2 3 #ifndef HEADER_H 4 #define HEADER_H 5 6 unsigned long returnFactorial(unsigned short num); 7 static const unsigned short headerNum = 5;//定义静态恒定值的全局变量 8 9 #endif 10 11 thatpp文件: 12 13 #include "header.h" 14 unsigned short thatNum = 8;//定义全局变量 15 bool printMe = true;//定义全局变量 16 17 unsigned long returnFactorial(unsigned short num) 18 25 if(printMe) 26 29 else 30 33 } 34 35 thispp文件: 36 37 #include "header.h" 38 #include "iostream" 39 using namespace std; 40 extern unsigned short thatNum;//声明全局变量 41 static bool printMe = false;//定义静态全局变量 42 int main() 43 52 return 0; 53 }


上一篇:Python基础入门学习笔记 003 小插曲之变量和字符串

下一篇:Python基础入门学习笔记 013元组:戴上了枷锁的列表


C/C++
Copyright © 2002-2019 k262电脑网 www.k262.cn 皖ICP备2020016292号
温馨提示:部分文章图片数据来源与网络,仅供参考!版权归原作者所有,如有侵权请联系删除!QQ:251442993 热门搜索 网站地图