#include<iostream>
using namespace std;
class Point{
private:
int x,y;
public:
Point(int x,int y):x(x),y(y){};
bool operator!=(const Point& p)const;
void ShowPosition();
};
bool Point::operator!=(const Point& p)const
{
if(x==p.x&&y==p.y)
return true;
return false;
}
void Point::ShowPosition()
{
cout<<x<<" "<<y<<endl;
}
int main(void)
{
Point p1(2,1);
Point p2(2,1);
Point p3(3,3);
if(p1!=p2)
cout<<"같다!"<<endl;
else
cout<<"다르다!"<<endl;
if(p2!=p3)
cout<<"같다!"<<endl;
else
cout<<"다르다!"<<endl;
}
'C++ > 열혈 C++' 카테고리의 다른 글
열혈 C++ 연습문제 10-2(cin 객체 <<연산자 오버로딩) (0) | 2018.04.08 |
---|---|
열혈 C++ 연습문제 10-1-3(+=연산자 오버로딩) (0) | 2018.04.08 |
열혈 C++ 연습문제 10-1-1 (-연산자 오버로딩) (0) | 2018.04.08 |
열혈 C++ oop 프로젝트 6단계 (2) | 2018.04.08 |
열혈 C++ 연습문제 8-3 (0) | 2018.04.08 |
댓글