Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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++ÖÐÊý×éÔªËØϱêÔ½½ç¿ÉÄÜÒýÆðµÄÎÊÌâ

Êý×éÊÇÀàÐÍÏàͬµÄ¶ÔÏóµÄÐòÁУ¬ÆäÖеĶÔÏó³ÆΪÊý×éÔªËØ¡£Ò²¿ÉÒÔ½«Êý×éÏëÏñ³ÉÒ»Á¬´®µÄÓÃϱêÖµ±àºÅµÄÏàÁÚ´æ´¢Çø¡£
       ¿ÉÄÜÔÚijЩ±à³ÌÓïÑÔÖУ¬Ò»¸öϱê±äÁ¿ÊDz»ÔÊÐí³¬³öÊý×鶨ÒåÖÐËùÉèµÄ½çÏ޵ġ£µ«ÊÇÔÚCºÍC++ÖУ¬Êý×éÊÇûÓÐÕâÖÖ°²È«´ëÊ©µÄ¡£ÏÂÃæÏÈÀ´¿´¿´Êý×éϱêÔ½½çµÄ¼¸ÖÖÒì³£½á¹û¡£
&nb ......

²éÕÒ×Ö·û´®ÖÐ×Ö·û²»Öظ´µÄ×î´ó×Ó´®(C/C++)

 //ÊäÈë²ÎÊý£º*str ËÑË÷×Ö·û´®
// subStrLen ÓÃÓÚ·µ»ØÕÒµ½µÄ×î´ó×Ó×Ö·û´®³¤¶È
//·µ»Ø£ºÕÒµ½µÄ×î´ó×Ó×Ö·û´®Ö¸Õë
char * findMaxSubStr(char *str, int &subStrLen){
char *subStr;
char *p = str;
int index[256] ;
for (int ix = 0; ix < sizeof(index)/sizeof(index[0]); ix++)
{
in ......

½ÌÄãÀí½â¸´ÔÓµÄC/C++ÉùÃ÷[ת]

Ô­ÎÄ£º
http://www.codeproject.com/cpp/complex_declarations.asp
×÷ÕߣºVikram A Punathambekar
½éÉÜ
Ôø¾­Åöµ½¹ýÈÃÄãÃԻ󲻽⡢ÀàËÆÓÚint * (* (*fp1) (int) ) [10];ÕâÑùµÄ±äÁ¿ÉùÃ÷Â𣿱¾ÎĽ«ÓÉÒ×µ½ÄÑ£¬Ò»²½Ò»²½½Ì»áÄãÈçºÎÀí½âÕâÖÖ¸´ÔÓµÄC/C++ÉùÃ÷£ºÎÒÃǽ«´ÓÿÌ춼ÄÜÅöµ½µÄ½Ï¼òµ¥µÄÉùÃ÷ÈëÊÖ£¬È»ºóÖð²½¼ÓÈëconstÐÞ ......

C ³ÌÐòµÄ´æ´¢¿Õ¼ä²¼¾Ö

C ³ÌÐòÓÐÏÂÃ漸¸ö²¿·Ö×é³É£º
  1  ÕýÎĶΣºÕâÊÇCPU Ö´ÐеĻúÆ÷Ö¸ÁîµÄ²¿·Ö¡£Í¨³£ÕýÎĶÎÊÇ¿ÉÒÔ¹²ÏíµÄ£¬ËùÒÔ¼´Ê¹ÊÇƵ·±Ö´ÐеijÌÐò£¨È磺Îı¾±à¼­Æ÷£©ÔÚ´æ´¢Æ÷ÉÏÒ²Ö»ÓÐÒ»¸ö¸±±¾¡£ÁíÍâÕýÎĶγ£³£ÊÇÖ»¶ÁµÄ£¬ÒÔ·ÀÖ¹³ÌÐòÒòΪÒâÍâ¶øÐÞ¸ÄÆä×ÔÉíµÄÖ¸Áî¡£
  2  ³õʼ»¯Êý¾Ý¶Î£ºÍ¨³£½«´Ë¶Î³ÆΪÊý¾Ý¶Î£¬Ëü°üº¬Á˳ÌÐò ......

C/C++ static µÄ×÷ÓÃ

ת×Ô£ºhttp://blog.csdn.net/xiaocai0001/archive/2006/04/14/662921.aspx
static¹Ø¼ü×ÖÊÇC, C++Öж¼´æÔڵĹؼü×Ö, ËüÖ÷ÒªÓÐÈýÖÖʹÓ÷½Ê½, ÆäÖÐÇ°Á½ÖÖÔÚC/C++ÓïÑÔÖÐʹÓÃ, µÚÈýÖÖÖ»ÔÚC++ÖÐʹÓÃ(C,C++ÖоßÌåϸ΢²Ù×÷²»¾¡Ïàͬ, ±¾ÎÄÒÔC++Ϊ׼).
(1)¾Ö²¿¾²Ì¬±äÁ¿
(2)Íⲿ¾²Ì¬±äÁ¿/º¯Êý
(3)¾²Ì¬Êý¾Ý³ÉÔ±/³ÉÔ±º¯Êý
ÏÂÃæ¾ÍÕâÈ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ