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

CµÄº¯ÊýÖ¸ÕëʵÏÖC++µÄ¶à̬

CµÄº¯ÊýÖ¸ÕëºÜÇ¿´ó£¬ÓúÃÁ˲ÅÊÇCÓïÑԵĸßÊÖ¡£ÏñGtkÖеĻص÷º¯ÊýµÄʹÓ㬶¼ÌåÏÖÁ˺¯ÊýÖ¸ÕëµÄÇ¿´óÍþÁ¦¡£
struct Point{
int x, y;
};
/*Shape*/
/*----------------------------------------------------------------*/
struct Shape {
struct Methods* methods;
};

struct Methods {//½«C++¶ÔÓ¦ÀàÖÐËùÓгÉÔ±º¯Êý·â×°µ½Ò»¸ö½á¹¹ÌåÀïÃæ
float (*getCircle)(Shape * shape);
float (*getArea)(Shape * shape);
void (*draw)(Shape * shape);
void (*move)(Shape * shape);
};
////////////////C++ Counterpart of above code//////////////////
class Shape {
public:
virtual float getCircle() = 0;
virtual float getArea() = 0;
virtual void draw() = 0;
virtual void move() = 0;
};
///////////////////////////////////////////////////////////////
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/*Rectangle*/
struct Rectangle {
struct Methods * methods; //°üº¬·â×°ºóµÄ³ÉÔ±º¯Êý½á¹¹ÌåµÄÖ¸Õë
Point leftTop; //ShapeÖ®ÍâÅÉÉúµÄ³ÉÔ±±äÁ¿
Point rightBottom; //ShapeÖ®ÍâÅÉÉúµÄ³ÉÔ±±äÁ¿
};
float Rectangle_getCircle(Shape * shape)
{
Rectangle * r = (Rectangle *) shape;
return (r->rightBottom.x - r->leftTop.x +
r->rightBottom.y - r->leftTop.y) * 2;
}
float Rectangle_getArea(Shape * shape){}
void Rectangle_draw (Shape * shape){}
void Rectangle_move(Shape * shape){}
struct Methods rectangleMethods = {
&Rectangle_getCircle,
&Rectangle_getArea,
&Rectangle_draw,
&Rectangle_move,
};
////////////////C++ Counterpart of above code//////////////////
class Rectangle : public Shape {
Point leftTop;
Point rightBottom;
public:
virtual float getCircle();
virtual float


Ïà¹ØÎĵµ£º

Ö÷Òª¹ØÓÚCµÄ±ê×¼»¯ÊäÊä³ö

ÍøÂçËѼ¯-×ÊÁÏ
¸ñʽ»¯ÊäÈëÊä³öº¯Êý
      Turbo C2.0 ±ê×¼¿âÌṩµÄÁ½¸ö¿ØÖÆ̨¸ñʽ»¯ÊäÈë¡¢ Êä³öº¯Êý£ºprintf( ) ¡¢scanf()¡£
      printf()º¯ÊýÓÃÀ´Ïò±ê×¼Êä³öÉ豸(ÆÁÄ»)дÊý¾Ý;
      scanf() º¯ÊýÓÃÀ´´Ó±ê×¼ÊäÈëÉ豸(¼ü ......

¸ßˮƽC³ÌÐòÔ±ÐÞÑø

ÔÚ´óÐÍCÓïÑÔÏîÄ¿¹¤³Ì»òÕßlinuxÄÚºËÖÐÎÒÃǶ¼»á¾­³£¼ûµ½Á½¸öFASTCALLºÍarmlinkage
Á½¸ö±êʶ·û(ÐÞÊηû)£¬ÄÇôËüÃǸ÷ÓÐʲô²»Í¬ÄØ£¿½ñÌì¾Í¸ø´ó¼Ò¹²Í¬·ÖÏíÒ»ÏÂ×Ô¼ºµÄÐĵÃ.
     ´ó¼Ò¶¼ÖªµÀÔÚ±ê×¼CϵÖк¯ÊýµÄÐβÎÔÚʵ¼Ê´«Èë²ÎÊýµÄʱºò»áÉæ¼°µ½²ÎÊý´æ·ÅµÄÎÊÌ⣬ÄÇôÕâЩ²ÎÊý´æ·ÅÔÚÄÄÀïÄØ£¿ ÓÐÒ»¶¨ÀíÂÛ»ù´¡µÄ ......

ѧϰlinuxϵÄc/c++±à³Ì

ѧϰlinuxϵÄc/c++±à³Ì  
1£¬ÏÈÓÐlinux»·¾³
´îminGWºÍcygwin¶¼ÓеãÂé·³£¬×î×î¼òµ¥µÄ°ì·¨»¹ÊÇ×°¸öÕæÕýµÄlinux£¬ÓÃÐéÄâ»úÒ²ºÃ£¬ÔÚÍøÂçÉϵÄÁíһ̨»úÆ÷Ò²ºÃ¡£ÕâÑù²»½ö¿ì£¬¶øÇÒÄãÓÐÁËÕæÕýµÄ»·¾³¡£
2.»áC/C++ÓïÑÔ£¨¹À¼ÆÄã»áµÄ£©
3.ÈëÃŽ׶ÎÊìϤgccÃüÁîÐУ¬×î»ù±¾µÄ²ÎÊý£¬È磬-g,-W,-O,-o,-c ½¨Òé¿´man gcc(ºÜ´óÕÒÏ ......

C×Ö·û´®³¤¶È¶¨Òå¹æ·¶

C×Ö·û´®³¤¶È¶¨Òå¹æ·¶
£¨×ªÔØÇë×¢Ã÷À´Ô´ÓÚ½ðÇìµÄרÀ¸£©
ÒòΪ×ÜÊǼûµ½C×Ö·û´®³¤¶ÈÏà¹ØµÄ´íÎó, ËùÓж¨¸ö¹æ·¶³öÀ´, ÓÐÀûÓÚ¼õÉÙ´íÎó.
¹Ø¼üÔÚÓÚC×Ö·û´®Óиö½áβ0, ´¦ÀíʱÐèҪעÒâ.
¶¨Òå×Ö·û´®³¤¶ÈÓÐÁ½ÖÖ·½Ê½, Ò»ÖÖÊÇÓÃ×Ö·û´®µÄ´óС, Ò»ÖÖÊÇ×Ö·û´®µÄ³¤¶È.
×Ö·û´®µÄ´óС¼´ÄÚ´æ¿Õ¼äµÄ´óС, ¶ø´®³¤¶È¼Ó1²ÅÊÇËùÐè¿Õ¼ä.   ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ