易截截图软件、单文件、免安装、纯绿色、仅160KB

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


相关文档:

教你理解复杂的C/C++声明[转]

原文:
http://www.codeproject.com/cpp/complex_declarations.asp
作者:Vikram A Punathambekar
介绍
曾经碰到过让你迷惑不解、类似于int * (* (*fp1) (int) ) [10];这样的变量声明吗?本文将由易到难,一步一步教会你如何理解这种复杂的C/C++声明:我们将从每天都能碰到的较简单的声明入手,然后逐步加入const修 ......

C 程序的存储空间布局

C 程序有下面几个部分组成:
  1  正文段:这是CPU 执行的机器指令的部分。通常正文段是可以共享的,所以即使是频繁执行的程序(如:文本编辑器)在存储器上也只有一个副本。另外正文段常常是只读的,以防止程序因为意外而修改其自身的指令。
  2  初始化数据段:通常将此段称为数据段,它包含了程序 ......

经典排序算法 C实现

PART (1)
/*
===============================================
经典排序思想,并用C语言指针实现排序算法
================================================
*/
/*
=============================================================================
相关知识介绍(所有定义只为帮助读者理解相关概念,并非严格定 ......

Linux下用eclipse写C/C++语言程序的编译问题

当要建立线程等时,在Linux下,用文本编辑,在键入“g++ -lpthread”.......“可以把库pthread引入”,编译通过。现在想用eclipse,但是默认情况下,引入不了pthread。会报“undefined reference to phread_create”等错误。
解决方法:可以在project中好到properties
在里面的&ldquo ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号