2-1 Point类的定义
来源:互联网 发布:skype6 下载 mac 编辑:程序博客网 时间:2024/05/17 23:56
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)
代码如下:
#include<iostream>using namespace std ;class stu{private: int x ; int y ;public: void SetPoint(int a,int b) { x = a ; y = b ; } void ShowPoint() { cout << "("<<x<<","<<y<<")"<<endl; }}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类的定义
- 在Mac上Git的使用(四)
- SpringMVC注解大全@Controller、@RequestMapping、@Resource和@Autowired等等
- jedis returnResource(jedis)问题
- 酷炫的RecyclerView开源库整理(未测)
- hdu 3248
- 2-1 Point类的定义
- codevs 1704 [NOI2001] 食物链 并查集
- 2017/10/25模拟赛总结
- 12-24小时制
- Libevnt 在Windows10 VS2015下分别编译32位和64位库
- java泛型小结
- Vue基础:组件--slot、异步组件、递归组件及其他
- 7 keys to better MySQL performance
- SpringCloud第八篇-Spring Cloud Config集群