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
Ïà¹ØÎĵµ£º
Precedence Operator Description Example Overloadable Associativity
1
::
Scope resolution operator
Class::age = 2;
no
none
2
()
()
[]
->
.
++
--
const_cast
dynamic_cast
static_cast
reinterpret_cast
typeid
Function call
Member initalization
Array access
Member access from ......
1.
ÔËÐÐʱ¿âµÄ·¾¶
Ö¸¶¨·½Ê½£º
£¨1£©
Á¬½ÓÑ¡Ïî
–libpath
£¨2£©
»·¾³±äÁ¿
ARMLIB
ÓÅÏȼ¶£º
libpath
¸ßÓÚ
ARMLIB
±»Ö¸¶¨µÄ·¾¶£º
°üº¬
a ......
×î½üÔÚcsdnµÄÂÛ̳ÉÏ·¢ÁËÕâÑùÒ»¸öÌû×ÓÈçÏÂ
int a=5;
a*=a/=a++;
ÎÒÔÚÒ»±¾¶þ¼¶cµÄÊéÉÏ¿´µ½µÄ´ð°¸ÊÇ2 ÓÉÓÚÎÒ¶Ô´ËÌâ²¢²»ÊÇÊ®·ÖÀí½â ËùÒÔÔÚÂÛ̳ÉÏ·¢±í ¿´ÓÐûÓÐÈËÄܰï׎âÊÍһϠȴûÓÐÏëµ½ÒýÀ´µÄ40¶àÂ¥µÄÒ»¸ö³¤Ìù ÒÔÖÁÓÚµ½×îºóÌÖÂÛµÄÄÚÈÝÔ¶Ô¶³¬¹ýµÄÌâÄ¿±¾Éí ÕæÊµ²»½â,ΪʲôÕâôÓÐÕùÒéµÄÌâÈ´ÄÃÀ´¿¼ÈË,Äѵ½¶¼Òª°´¶þ¼¶cµÄvc±àÒ ......
ÔÚʹÓÃCÓïÑÔ±àд´óÐ͹¤³ÌʱҪÓõ½ÃæÏò¶ÔÏóÓïÑÔÖеÄÒ»Ð©ÌØÐÔ£¨ÄÚºËÖÐijЩ²¿·Ö¾ÍÓ¦ÓÃÁËÕâÐ©ÌØÐÔ£©¡£CÓïÑÔÊÇ»ùÓÚÎļþµÄÀ࣬static¹Ø¼ü×ÖÉùÃ÷˽ÓÐÊý¾Ý³ÉÔ±£¬¹«ÓÐÊý¾Ý³ÉÔ±±ØÐ붨Ò嵽ͷÎļþ£¬»òÓÉÆäËüÎļþʹÓÃextern¹Ø¼ü×ÖÉùÃ÷À´Ê¹Óᣵ«ºóÕßÒýÓùØÏµ²»ÇåÎú¡£Í·Îļþ¾Í³ÉÁ˹«ÓÐÊý¾Ý³ÉÔ±ÉùÃ÷µÄµØ·½¡£
Í·ÎļþÖÐÓ¦¸Ã°üº¬ÒÔϼ°·½ÃæÄÚ ......
C×Ö·û´®³¤¶È¶¨Ò广·¶
£¨×ªÔØÇë×¢Ã÷À´Ô´ÓÚ½ðÇìµÄרÀ¸£©
ÒòΪ×ÜÊǼûµ½C×Ö·û´®³¤¶ÈÏà¹ØµÄ´íÎó, ËùÓж¨¸ö¹æ·¶³öÀ´, ÓÐÀûÓÚ¼õÉÙ´íÎó.
¹Ø¼üÔÚÓÚC×Ö·û´®Óиö½áβ0, ´¦ÀíʱÐèҪעÒâ.
¶¨Òå×Ö·û´®³¤¶ÈÓÐÁ½ÖÖ·½Ê½, Ò»ÖÖÊÇÓÃ×Ö·û´®µÄ´óС, Ò»ÖÖÊÇ×Ö·û´®µÄ³¤¶È.
×Ö·û´®µÄ´óС¼´ÄÚ´æ¿Õ¼äµÄ´óС, ¶ø´®³¤¶È¼Ó1²ÅÊÇËùÐè¿Õ¼ä.   ......