2-1 Point类的定义
来源:互联网 发布:主板有什么作用知乎 编辑:程序博客网 时间:2024/05/21 06:40
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;int main(){ cout<<"(10,11)"<<endl; return 0;}但是这样水了这道题不是我的风格。。。
于是自找麻烦的写了。。。
#include <iostream>using namespace std;class pos{private: int x=10; int y=11;public: void setpoint(int nx,int ny) { x=nx; y=ny; } void showpoint() { cout<<"("<<x<<","<<y<<")"<<endl; }};int main(){ pos p; p.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类的定义
- The server quit without updating PID file (/var/run/mysqld/mysqld.pid)
- silverlight中ItemsSource和DataContext的用法注意
- springmvc全局异常处理
- log4j,slf4j及Commons Logging介绍与原理使用
- Java学习笔记之Integer自动拆装箱、数据常量池
- 2-1 Point类的定义
- AS 快捷键改成Ec
- PHP:冒泡排序、快速查找和二分查找的思路以及算法
- 个性化 git log 输出
- Qt的信号与槽你可能不知道的那些
- 在mvc4里怎样引用:System.Web.Optimization和entityframework
- 取某个时间段某个值的平均值要求按日取值
- 牛客网台阶问题源码实现 动态规划
- 统计学习-感知机