organizing code files in C & C++
http://www.gamedev.net/reference/programming/features/orgfiles/page2.asp
通过四个pitfall讲解头文件的由来和好处,以及使用头文件定义inline func and template.
Remember that, as far as the compiler is concerned, there is absolutely no difference between a header file and a source file.
The key idea is that headers contain the interface, and the source files contain the actual implementation.This means that one source file uses another source file via the second source file's header.
main body
By now you're probably convinced that there are benefits to splitting up your project into several smaller files. So, how would you go about it? Although some of the decisions you make will be reasonably arbitrary, there are some basic rules that you should follow to ensure that it all works.
Firstly, look at how you would split your code into sections. Often this is by splitting it into separate subsystems, or 'modules', such as sound, music, graphics, file handling, etc. Create new files with meaningful filenames so that you know at a glance what kind of code is in them. Then move all the code that belongs to that module into that file. Sometimes you don't have clear module - some would say this should send out warnings about the quality of your design! There may still be other criteria you use for splitting up code, such as the structures it operates upon. (Often "general purpose" functions can be split into string-handling and number-handling, for example.) And occasionally a module could be split into two or more files, because it might make sense to do so on logical grounds.
Once you have split it up in this way into separate source files, the next stage is to consider what will go into the header files. On a very simple level, code that you usually put at the top of the source file is a prime candidate for moving into a separate header file. This is presumably why they got termed 'header' files, after all.
This code to go in a header usually includes some or all
相关文档:
一、屏幕操作函数
1. clrscr()清除字符窗口函数
2. window()字符窗口函数
3. gotoxy()光标定位函数
4. clreol() 清除光标行尾字符函数
5. insline() 插入空行函数
6. delline() 删除一行函数
7. gettext() 拷进文字函数
8. puttext() 拷出文字函数
9. movetext() 移动文字函数
二、字符属性函数
10. textmode( ......
【1】 “ = ”的优先级低于 “ || ” 且 “ = ” 为右结合性,注意一下代码为死循环:while(c=' '||c=='\t'||c=='\n')
程序本意是跳过空格,制表符,换行符,但由于不小心将c==' '写成了c= ' '导致程序进入死循环
【2】a=-1 在很老的C版本里理解为 a =- 1
【3 ......
索引:
1 输入与输出
1.1 文件操作
1.1.1 fopen
1.1.2 freopen
1.1.3 fflush
1.1.4 fclose
1.1.5 remove
1.1.6 rename
1.1.7 tmpfile
1.1.8 tmpnam
1.1.9 setvbuf
1.1.10 setbuf
1.2 格式化输出
1.2.1 fprintf
1.2.2 printf
1.2.3 sprintf
1.2.4 snprintf
1.2.5 vprintf
1.2.6 vfprintf
1.2.7 vsprintf ......
GCC 中文手册
http://www.nbfan.com/forum/dispbbs....&ID=1433&page=1
GNU make 指南
http:/ ......