基本介紹
- 中文名:j靜態聯編
- 別稱:靜態束定
- 性質:名詞
- 用於:編程
含義,舉例,
含義
在編譯時所進行的這種聯編又稱靜態束定,在編譯時就解決了程式中的操作調用與執行該操作代碼間的關係。
舉例
一個靜態聯編的例子。
(動畫7_6)
#include<iostream.h>
class point{ private: float x, y;
public:
void setPoint(float I, float j)
{ x=I;
y=j;
}
float area( )
{ return 0;}
};
const float pi=3.14159;
class circle:public point
{ private: float radius;
public:
void setRadius( float r)
{ radius =r; }
float area( )
{ return pi*radius*radius;}
};
void mian()
{ point p;
float a=p.area();//調用point類的成員函式
cout<<"the area of the point p is"<<a<<endl;
circle c;
c.setRadius(2.5);
a=c.area(); //調用circle類的成員函式
cout<<"the area of the circle c is"<<a<<endl;
}
程式結果為:
the area of the point p is 0
the area of the circle c is 19.634937
