2-1 Point类的定义
来源:互联网 发布:python 内存管理 编辑:程序博客网 时间:2024/05/16 08:50
problem
2-1 Point类的定义
Time Limit: 1000MS Memory Limit: 65536KB
Submit Statistic
Problem Description
通过本题目的练习可以掌握类与对象的定义;
设计一个点类Point,它具有私有数据成员x(横坐标)、y(纵坐标);公有成员函数:SetPoint(int,int)用于设置点对象的值,ShowPoint()用于输出点对象的信息
在主函数中调用成员函数SetPoint(int,int)为点对象设置值,并调用成员函数ShowPoint()输出点的信息。
Input
无
Output
一对圆括号内,x和y的值用逗号间隔
Example Input
无
Example Output
(10,11)
Hint
Author
黄晶晶
code
#include <iostream>using namespace std;class point{private: int p_x, p_y;public: void SetPoint(int x,int y); void ShowPoint();};void point::SetPoint(int x, int y){ p_x = x; p_y = y;}void point::ShowPoint(){ cout << '(' << p_x << ',' << p_y << ')' << endl;}int main(){ point myPoint; int x = 10, y = 11; myPoint.SetPoint(x,y); myPoint.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类的定义
- 使用Servlet上传多张图片——Dao层(BaseDao.java)
- POJ 2151 Check the difficulty of problems 概率DP入门
- 使用Servlet上传多张图片——Dao层(ProductInfoDao.java)
- domain,DNS,冗余,DNS劫持的大致原理
- VMware通过vmdk文件创建虚拟机
- 2-1 Point类的定义
- Spring Boot 中集成 Spring Security
- 结合redis设计与实现的redis源码学习-8.0-object(对象)
- 2017阿里云栖大会PaaS方向内容概要
- 比尔·盖茨的传奇
- 使用Servlet上传多张图片——Service层(ProductInfoService.java和ProductInfoServiceImpl)
- Pycharm中一些不为人知的技巧
- struts2实现文件上传
- 微信抢票的一些感想