sdut 3-1 Point类的构造函数
来源:互联网 发布:linux创建文件目录 编辑:程序博客网 时间:2024/06/06 05:31
3-1 Point类的构造函数
Time Limit: 1000MS Memory limit: 65536K
题目描述
通过本题目的练习可以掌握类的构造函数的定义;
设计一个点类Point,私有数据成员有x、y;公有成员函数有:无参数的构造函数Point(),带参数的构造函数Point(int,int);ShowPoint()输出点对象的信息
在主函数main()中调用相应成员函数,从键盘接收时间对象的x和y的值,并向显示器输出相应的值。
输入
输入2个整数,用一个空格间隔
输出
要求先输出默认的点值,再输出用户构造的点的值
点的格式为:一对圆括号内 x,y的值,中间用“,”间隔;
示例输入
10 11
示例输出
(0,0)(10,11)
提示
来源
黄晶晶
示例程序
#include <iostream>using namespace std;class point{private : int x; int y;public : point(int a=0, int b=0) { x=a; y=b; } void set() { cin>>x>>y; } void show() { cout<<'('<<x<<','<<y<<')'<< endl; }};int main(){ int x,y; point a; point b; b.set(); a.show(); b.show(); return 0;}
0 0
- [2670]3-1 Point类的构造函数 SDUT
- sdut 3-1 Point类的构造函数
- 3-1 Point类的构造函数-SDUT
- SDUT-2670 3-1 Point类的构造函数
- sdut oj3-1 Point类的构造函数
- 3-1 Point类的构造函数
- 3-1 Point类的构造函数
- 3-1 Point类的构造函数
- 3-1 Point类的构造函数
- 3-1 Point类的构造函数
- 3-1 Point类的构造函数
- 3-1 Point类的构造函数
- 3-1 Point类的构造函数
- 3-1 Point类的构造函数
- 3-1 Point类的构造函数
- 3-1 Point类的构造函数
- 3-1 Point类的构造函数
- 3-1 Point类的构造函数
- ZOJ Problem Set - 1188 DNA Sorting
- 判断子序列、求最长公共子序列算法实现
- tomcat 卡死 Initializing Spring root WebApplicationContext
- Xcode6编译SDWebImage报错解决方法(SDWebImageDownloaderOperation.m错误)
- HDU 2.1.1最小公倍数
- sdut 3-1 Point类的构造函数
- 美团二面经验
- 输入两个整数n和m, 从数列1,2,...,n中任意选择几个数,使其和等于m, 要求编写程序输出所有的组合
- an android virtual device that failed to load 安卓虚拟机无法启动
- 文件的读写操作
- window.open以post方式提交
- ADSL宽带为什么下载和上传速度差别如此之大?
- PAT 1015. 德才论 (25)
- OC第三题通讯录