2-1 Point类的定义
来源:互联网 发布:mac卸载自带软件卸载 编辑:程序博客网 时间:2024/05/18 01:07
2-1 Point类的定义
Time Limit: 1000MS Memory limit: 65536K
题目描述
通过本题目的练习可以掌握类与对象的定义;
设计一个点类Time,它具有私有数据成员x(横坐标)、y(纵坐标);公有成员函数:SetPoint(int,int)用于设置点对象的值,ShowPoint()用于输出点对象的信息
在主函数中调用成员函数SetPoint(int,int)为点对象设置值,并调用成员函数ShowPoint()输出点的信息。
输入
无
输出
一对圆括号内,x和y的值用逗号间隔
示例输入
无
示例输出
(10,11)
提示
来源
黄晶晶
示例程序
#include <iostream>using namespace std;class Time{private: int x; int y;public: void SetPoint(int a,int b) { x=a; y=b; } void ShowPoint() { cout<<"("<<x<<","<<y<<")"; }}T;int main(){ T.SetPoint(10,11); T.ShowPoint(); return 0;}
0 0
- 2-1 Point类的定义
- sdut 2-1 Point类的定义
- 2-1 Point类的定义
- 2-1 Point类的定义
- 2-1 Point类的定义
- 2-1 Point类的定义
- 2-1 Point类的定义
- 2-1 Point类的定义
- 2-1 Point类的定义
- 2-1 Point类的定义
- C++ 2-1 Point类的定义
- 2-1 Point类的定义
- 2-1 Point类的定义
- 2-1 Point类的定义
- 2-1 Point类的定义
- 2-1 Point类的定义
- 2-1 Point类的定义
- 2-1 Point类的定义
- 【JAVA程序员面试宝典】2天看完了-谈谈我的理解吧
- acdream 1205 Disappeared Block 离线
- Node.js 初学者入门
- 了解散列算法
- C++ 第二天学习
- 2-1 Point类的定义
- 线上应用故障排查:高内存占用
- 时间管理
- [windows C/C++]面试准备(二)多线程面试题1
- hbase shell 命令
- 高精度计算bign类
- 模拟CSDN请求,做一点事
- iOS_31_cocos2d_消息调度
- Java问题排查常用linux命令