词条 | j静态联编 |
释义 | 静态联编是指联编工作出现在编译连接阶段,这种联编又称早期联编,它解决了程序中的操作调用与执行该操作代码间的关系。 静态联编 静态联编含义: 在编译时所进行的这种联编又称静态束定,在编译时就解决了程序中的操作调用与执行该操作代码间的关系。 例7.3.1 一个静态联编的例子。 (动画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 |
随便看 |
百科全书收录4421916条中文百科知识,基本涵盖了大多数领域的百科知识,是一部内容开放、自由的电子版百科全书。