现在的位置: 首页 > 综合 > 正文

期末复习

2013年09月07日 ⁄ 综合 ⁄ 共 1190字 ⁄ 字号 评论关闭

the life of the software

 

I decide to suffer the diseases to creat my life of the software.

//、、、用琐碎的时间治疗她。
//、、运算符
//'''多态性:一个接口,多种方法,一个名字定义不同函数,which 执行不同却有类似操作,
她和联编有关:
高效的静态联编,编译时多态性,运算符重载和函数重载complete。
和程序以维护的的动态联编.运行时多态性,继承和多态realize。
函数重载:成员函数和构造函数
 函数重载p31:
 1;const,number,type.!=return type
 2;二义性:int aoker(int x=0,int y=0);
 3;实际参数和形式参数的转换;
//复习构造函数
//eg:
#include<iostream.h>
class point{
 int x,y;
public:
 point(int a,int b)
 {x=a;y=b;}
 float area()
 {return 0.0;}
};
class circle:public point{
 int radius;
public:
 circle(int x,int y,int r):point(x,y)
 {radius=r;}
 float area()
 {return 3.1416*radius*radius;}
};
int main()
{
 point p(23,28);
 circle c(3,4,31);
 cout<<p.area()<<endl;
 cout<<c.area()<<endl;
 cout<<c.point::area()<<endl;
 return 0;
}
/*//重载运算符+
#include<iostream.h>
class complex{
public:
 double real;
 double imag;
 complex( double r=0, double i=0)
 {real=r;imag=i;}
};
complex operator+(complex col,complex co2)
{
 complex temp;
 temp.real=col.real+co2.real;
 temp.imag=col.imag+co2.imag;
 return temp;
}
int main()
{
 complex com1(1.9,1.9),com2(1,2),total1,total2;
 total1=operator+(com1,com2);
 cout<<"real1="<<total1.real<<" "<<"image="<<total1.imag<<endl;
 total2=com1+com2;
 cout<<"total2="<<total2.real<<" "<<"imag2="<<total2.imag<<endl;
 return 0;
}

抱歉!评论已关闭.