第10周项目一-点-圆-圆柱类的设计(1)

来源:互联网 发布:唱歌培训软件 编辑:程序博客网 时间:2024/05/01 16:39

代码;

/**Copyright (c) 2016, 烟台大学计算机与控制工程学院*All rights reserved.*文件名称:main.cpp;*作    者:岳成艳;*完成日期:2015年5月6号;*版 本 号:vc++6.0;**问题描述:建立一个point类,包括数据成员x,y,实现需要的函数 。*程序输入:略;*程序输出:略;*/#include<iostream>using namespace std;class Point{public:    Point(double a=0,double b=0);    void show_point();    double getx(){return x;}    double gety(){return y;}protected:    double x;    double y;};Point::Point(double a,double b){    x=a;    y=b;}void Point::show_point(){    cout<<"点的坐标为:"<<x<<","<<y<<endl;}int main(){    Point p1(1,2);    p1.show_point();    return 0;}

运行测试:


0 0
原创粉丝点击