欢迎来到天天文库
浏览记录
ID:38765547
大小:270.50 KB
页数:5页
时间:2019-06-19
《《C++面向对象程序设计》实验三》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、《C++面向对象程序设计》实验3报告三、代码题1:#includeusingnamespacestd;classVector{public:int*data;//向量各维数值指针intn;//定义向量维数Vector(){data=NULL;n=3;}Vector(intlen);~Vector(){if(data!=NULL)deletedata;}//析构函数实现向量动态内存的释放Vector(Vector&t);int&operator[](intx);intoperator*(Vector
2、&v);Vectoroperator+(Vector&v);Vectoroperator-(Vector&v);voidLinearly(Vector&v);friendostream&operator<<(ostream&output,Vector&v);//友员函数实现向量输出voiddisplay(Vectorc){for(inti=0;i3、t[len];n=len;}Vector::Vector(Vector&t){n=t.n;data=newint[t.n];for(inti=0;i4、i++){Temp.data[i]=data[i]+v.data[i];//cout<5、mp(n);for(inti=0;i6、试重载赋值运算符'+'v4.display(v2-v1);//测试重载赋值运算符'-'sum=v1*v2;cout<<"v1*v2="<usingnamespacestd;classFigure{protected:doublex,y;public:voidset(doublei,doublej){x=i;y=j;}virtualvoidarea()=0;};classVolume{protected:doublex,y,z;public:voidse7、t(doublei,doublej,doublek){x=i;y=j;z=k;}virtualvoidvol()=0;};classEllipse:publicFigure{public:voidarea(){cout<<"椭圆面积="<8、blei,doublej,doublek){x=i;y=j;z=k;}};classCylindroid2:publicVolume{public:voidvol(){cout<<"椭圆柱体积="<
3、t[len];n=len;}Vector::Vector(Vector&t){n=t.n;data=newint[t.n];for(inti=0;i4、i++){Temp.data[i]=data[i]+v.data[i];//cout<5、mp(n);for(inti=0;i6、试重载赋值运算符'+'v4.display(v2-v1);//测试重载赋值运算符'-'sum=v1*v2;cout<<"v1*v2="<usingnamespacestd;classFigure{protected:doublex,y;public:voidset(doublei,doublej){x=i;y=j;}virtualvoidarea()=0;};classVolume{protected:doublex,y,z;public:voidse7、t(doublei,doublej,doublek){x=i;y=j;z=k;}virtualvoidvol()=0;};classEllipse:publicFigure{public:voidarea(){cout<<"椭圆面积="<8、blei,doublej,doublek){x=i;y=j;z=k;}};classCylindroid2:publicVolume{public:voidvol(){cout<<"椭圆柱体积="<
4、i++){Temp.data[i]=data[i]+v.data[i];//cout<5、mp(n);for(inti=0;i6、试重载赋值运算符'+'v4.display(v2-v1);//测试重载赋值运算符'-'sum=v1*v2;cout<<"v1*v2="<usingnamespacestd;classFigure{protected:doublex,y;public:voidset(doublei,doublej){x=i;y=j;}virtualvoidarea()=0;};classVolume{protected:doublex,y,z;public:voidse7、t(doublei,doublej,doublek){x=i;y=j;z=k;}virtualvoidvol()=0;};classEllipse:publicFigure{public:voidarea(){cout<<"椭圆面积="<8、blei,doublej,doublek){x=i;y=j;z=k;}};classCylindroid2:publicVolume{public:voidvol(){cout<<"椭圆柱体积="<
5、mp(n);for(inti=0;i6、试重载赋值运算符'+'v4.display(v2-v1);//测试重载赋值运算符'-'sum=v1*v2;cout<<"v1*v2="<usingnamespacestd;classFigure{protected:doublex,y;public:voidset(doublei,doublej){x=i;y=j;}virtualvoidarea()=0;};classVolume{protected:doublex,y,z;public:voidse7、t(doublei,doublej,doublek){x=i;y=j;z=k;}virtualvoidvol()=0;};classEllipse:publicFigure{public:voidarea(){cout<<"椭圆面积="<8、blei,doublej,doublek){x=i;y=j;z=k;}};classCylindroid2:publicVolume{public:voidvol(){cout<<"椭圆柱体积="<
6、试重载赋值运算符'+'v4.display(v2-v1);//测试重载赋值运算符'-'sum=v1*v2;cout<<"v1*v2="<usingnamespacestd;classFigure{protected:doublex,y;public:voidset(doublei,doublej){x=i;y=j;}virtualvoidarea()=0;};classVolume{protected:doublex,y,z;public:voidse
7、t(doublei,doublej,doublek){x=i;y=j;z=k;}virtualvoidvol()=0;};classEllipse:publicFigure{public:voidarea(){cout<<"椭圆面积="<8、blei,doublej,doublek){x=i;y=j;z=k;}};classCylindroid2:publicVolume{public:voidvol(){cout<<"椭圆柱体积="<
8、blei,doublej,doublek){x=i;y=j;z=k;}};classCylindroid2:publicVolume{public:voidvol(){cout<<"椭圆柱体积="<
此文档下载收益归作者所有