Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

C: ÃæÏò¶ÔÏó(2)

ÑÝʾÈçºÎÓÃCʵÏּ̳У¬ÖØÔØÖ®ÀàµÄÍæÒÕ¶ù¡£VC++6.0±àÒëͨ¹ý¡£
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifndef class
        #define class struct
#endif
#ifndef private
        #define private
#endif
#ifndef public
        #define public
#endif
#ifndef protected
        #define protected
#endif
#ifndef bool
        #define bool int
#endif
#ifndef true
        #define true 1
#endif
#ifndef false
        #define false 0
#endif
class Parent{
 //private members
 private class Parent *this;
 private char *name;
 //public members
 public void (*construct)(class Parent *this);
 public bool (*setName)(class Parent *this, const char *name);
 public char* (*getName)(class Parent *this);
 public void (*destruct)(class Parent *this);
};
class Son{
 //private members
 private class Son *this;
 //inherit properties from Parent, we use a pointer here to simulate inheritance
 private class Parent *inherit;
 //add new members
 private char* addr;
//public members
 public bool (*construct)(class Son *this); 
 public bool (*setName)(class Son *this, const char *name);
 public char* (*getName)(class Son *this);
 public bool (*setAddr)(class Son *this, const char *addr);
 public char* (*getAddr)(class Son *this);
 public void (*destruct)(class Son *this);
};
//foward declaration
//-----Members for Parent begin
void ParentConstruct(class Parent *this);
bool setName(class Parent *this, const char *name);
char *getName(class Parent *this);
void ParentDestruct(class Parent *this);
//-----Mmmbers for Parent end
//----Members for Son begin
bool SonConstruct(clas


Ïà¹ØÎĵµ£º

CºÍC++ÓïÑÔѧϰ×ܽá(Ò»)

CºÍC++ÓïÑÔѧϰ×ܽá(Ò»)
֪ʶ½á¹¹:
1¡¢if,for,switch,goto
2¡¢#define,const
3¡¢Îļþ¿½±´µÄ´úÂë,¶¯Ì¬Éú³ÉÄÚ´æ,¸´ºÏ±í´ïʽ,strcpy,memcpy,sizeof
4¡¢º¯Êý²ÎÊý´«µÝ,ÄÚ´æ·ÖÅ䷽ʽ,ÄÚ´æ´íÎó±íÏÖ,mallocÓënewÇø±ð
5¡¢ÀàÖØÔØ¡¢Òþ²ØÓ븲¸ÇÇø±ð,externÎÊÌâ,º¯Êý²ÎÊýµÄȱʡ
ÖµÎÊÌâ,ºê´úÂëÓëÄÚÁªº¯ÊýÇø±ð
6¡¢¹¹ÔìºÍÎö¹ ......

CÃæÊÔÌâ»ã×Ü

1¡¢  int a=2,b=11,c=a+b++/a++; ÔòcֵΪ¶àÉÙ£¿
¡¾¿¼µã¡¿±àÂë¹æ·¶¡£
±íÃæÉÏ¿¼²ìÄã¶ÔÔËËã·ûÓÅÏȼ¶µÄÕÆÎճ̶ȣ¬µ«Êµ¼ÊÉÏÓÅÏȼ¶ÕâÐ©ÍæÒâºÜÄÑËÀ¼ÇÓ²±³µÃס£¿´ó¼ÒµÄÒɻ󲻾ÍÊÇÔËËã·ûµÄ½áºÏ˳Ðòô£¿ÄÇôÈçºÎÈ¥±ÜÃâÄØ£¿c=a+((b++)/(a++))²»¾ÍÐÐÁËô£¬ÆäʵÎÊÌâ±³ºó¿¼²ìµÄÊÇÄãµÄ±àÂë¹æ·¶£¬ÈçºÎдÇåÎúÒ×¶®µÄ´úÂ룬ÈçºÎÔÚÒ»¸öÍÅ ......

C±ä²Îº¯ÊýµÄʵÏÖ»úÖÆ

CµÄ±ä²ÎÎÊÌâÓëprintº¯ÊýµÄʵÏÖ
ÎÒÃÇÔÚCÓïÑÔ±à³ÌÖлáÓöµ½Ò»Ð©²ÎÊý¸öÊý¿É±äµÄº¯Êý,ÀýÈçprintf() Õâ¸öº¯Êý,ËüµÄ¶¨ÒåÊÇÕâÑùµÄ: int printf( const char* format, ...); 
Ëü³ýÁËÓÐÒ»¸ö²ÎÊýformat¹Ì¶¨ÒÔÍâ,ºóÃæ¸úµÄ²ÎÊýµÄ¸öÊýºÍÀàÐÍÊǿɱäµÄ,ÀýÈçÎÒÃÇ¿ÉÒÔÓÐÒÔϲ»Í¬µÄµ÷Ó÷½·¨:
   printf("%d",i);
&nb ......

c/c++±ÊÊÔÌâÄ¿(ÁÖÈñ)

±¾ÊÔÌâ½öÓÃÓÚ¿¼²éC++/C³ÌÐòÔ±µÄ»ù±¾±à³Ì¼¼ÄÜ¡£ÄÚÈÝÏÞÓÚC++/C³£ÓÃÓï·¨£¬²»Éæ¼°Êý¾Ý½á¹¹¡¢Ëã·¨ÒÔ¼°Éî°ÂµÄÓï·¨¡£¿¼ÊԳɼ¨ÄÜ·´Ó³³ö¿¼ÉúµÄ±à³ÌÖÊÁ¿ÒÔ¼°¶ÔC++/CµÄÀí½â³Ì¶È£¬µ«²»ÄÜ·´Ó³¿¼ÉúµÄÖÇÁ¦ºÍÈí¼þ¿ª·¢ÄÜÁ¦¡£
±ÊÊÔʱ¼ä90·ÖÖÓ¡£Ç뿼ÉúÈÏÕæ´ðÌ⣬ÇÐÎðÇáÊÓ¡£
Ò»¡¢ÇëÌîдBOOL , float, Ö¸Õë±äÁ¿ Óë“ÁãÖµ”±È½ÏµÄ i ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ