对象数组
2016-04-09 19:31
218 查看
#include<iostream> using namespace std; class Point { public: Point() : _x(0), _y(0) {}; Point(int x, int y) : _x(x), _y(y) {}; ~Point() {}; void setX(int x){ _x = x; } void setY(int y){ _y = y; } int getX() const { return _x; } int getY() const { return _y; } private: int _x, _y; }; int main() { Point *ptr=new Point[5]; for(int i=0;i<5;i++) { int xx,yy; cin>>xx>>yy; ptr[i].setX(xx),ptr[i].setY(yy); cout<<ptr[i].getX()<<'\t'<<ptr[i].getY()<<endl;; } delete []ptr; return 0; }
相关文章推荐
- inet_ntoa之坑------再谈不可重入函数中的static
- ZooKeeper的工作流程
- 结对编程作业——电梯调度
- 【Linux学习】epoll详解
- .net反射
- GCJ Qualification Round 2016 C题
- iOS如何上传代码到Github
- Problem 1603 - Minimum Sum 【好题】
- POJ 3768 Repeater
- 设置web页面favicon设置问题
- Java深克隆和浅克隆的原理及实现
- c3p0配置文件报错 对实体 "characterEncoding" 的引用必须以 ';' 分隔符结尾。
- 《leetCode》:Isomorphic Strings
- HDU 2076 夹角有多大(题目已修改,注意读题)
- 使用 Shell 脚本自动化 Linux 系统维护任务
- 笨方法解决锐捷校园网环境下VMware虚拟机无法上网问题(Fedora试用上网成功)
- Linux下select, poll和epoll IO模型的详解
- HDOJ 2058 The sum problem
- 分布式版本控制系统Git------版本控制(文末有一个小疑问)
- socket编程UDP小例子