第十周实验报告3
来源:互联网 发布:牛尔的产品知乎 编辑:程序博客网 时间:2024/05/28 09:34
程序头部注释开始
* 程序的版权和版本声明部分
* Copyright (c) 2012, 烟台大学计算机学院学生
* Copyright (c) 2012, 烟台大学计算机学院学生
* All rights reserved.
* 文件名称:
* 作 者: 于昊
* 完成日期: 2012 年4 月 22日
* 版 本 号: v1
* 对任务及求解方法的描述部分
* 输入描述:……
* 问题描述:……
* 程序输出:……
* 程序的版权和版本声明部分
* Copyright (c) 2012, 烟台大学计算机学院学生
* Copyright (c) 2012, 烟台大学计算机学院学生
* All rights reserved.
* 文件名称:
* 作 者: 于昊
* 完成日期: 2012 年4 月 22日
* 版 本 号: v1
* 对任务及求解方法的描述部分
* 输入描述:……
* 问题描述:……
* 程序输出:……
* 程序头部的注释结束*
#include<iostream.h>class Point{public:void display();Point(int=0, int=0);friend ostream&operator<<(ostream&,Point&);protected:int x;int y;};class Circle{public:Circle(int=0);void display();double Area(int);protected:int r;};class Cylinder:public Point,public Circle{public:Cylinder(int =0,int=0,int=0,int=0);void display();double Volume(int ,int );friend ostream&operator<<(ostream&,Cylinder&);protected:int h;};ostream&operator << (ostream&output,Cylinder&c){ output<<"此点的坐标是 :"<<"("<<c.x<<","<<c.y<<")"<<endl;output<<"此圆的半径是是 :"<<c.r<<endl;output<<"此圆的面积是 :"<<c.Area(c.r)<<endl;output<<"此圆的体积是 :"<<c.Volume(c.r,c.h)<<endl;return output;}void Point::display(){cout<<"该点的坐标是:("<<x<<","<<y<<")"<<endl;}Point::Point(int x,int y){this->x=x;this->y=y;}Circle::Circle(int r){this->r=r;}double Circle::Area(int r ){return (3.1415*r*r);}Cylinder::Cylinder(int x,int y,int r,int h):Point(x,y),Circle(r){this->h=h;}double Cylinder::Volume(int r,int h){return (3.1415*r*r*h);}void Cylinder::display(){cout<<"此点的坐标是 :"<<"("<<x<<","<<y<<")"<<endl;cout<<"此圆的半径是是 :"<<r<<endl;cout<<"此圆的面积是 :"<<Area(r)<<endl;cout<<"此圆的体积是 :"<<Volume(r,h)<<endl;}int main(){Cylinder c2(5,5,5,5);c2.display();return 0;}1.自己的原创,还是头文件的问题,通过上网百度得出的修改方法,的但用法还是不太明白,课本上虽然这么说,却不知道为啥这么用,不知以后再编程
的时候这种漏洞会不会再次出现。把#include <iostream> using namespace std;换成#include<iostream.h> .不知道有何区别。
2.继承的方式不是class3 继承class2 再继承基类class1,而是用class3直接去继承class2和class3,class2和class3其实都是class1的基类。
3.重载,主要是头文件的问题。
- 第十周实验报告3
- 第十周实验报告3
- 第十周实验报告3
- 第十周实验报告3
- 第十周实验报告3
- 第十周实验报告3
- 第十周实验报告3
- 第十周实验报告
- 第十周实验报告
- 《第十周实验报告任务3》
- 第十周实验报告(3)
- 第十周实验报告(任务3)
- 第十周实验报告任务3
- 第十周实验报告(3)
- 第十周实验报告(3)
- 第十周实验报告1
- 第十周实验报告2
- 第十周实验报告1
- Linux与Unix
- iOS5分享 UITableView全新特性
- 解决如何使用opengl超级宝典中实例代码及shared文件夹里的库
- locate 和 find:两个查找文件的命令
- C++ Chapter 6. Inheritance and Object-Oriented Design
- 第十周实验报告3
- Square类型的移动支付,移动POS机
- ORACLE Varaible
- 系统引导时为什么要关闭Caches?
- CUDA学习笔记
- C/C++绘制余弦曲线
- Android4.0.3 显示系统深入理解
- 设计模式(1)-创建型-单件(Singleton)模式 (个人笔记)
- Struts实现上传、下载