c++ 복습
#include <iostream>
using namespace std;
class Rect;
bool equals(Rect r, Rect s);
class Rect {
int w, h;
public:
Rect(int w, int h) { this->w = w; this->h = h; };
friend bool equals(Rect r, Rect s);
};
bool equals(Rect r, Rect s) {
if (r.w == s.w && r.h == s.h)return true;
else return false;
}
int main()
{
Rect a(3, 4), b(4, 5);
if (equals(a, b))cout << "equals" << endl;
else cout << "not equals" << endl;
return 0;
}
#include <iostream>
using namespace std;
class Rect;
class RectManager {
public:
bool equals(Rect r, Rect s);
};
class Rect {
int w, h;
public:
Rect(int w, int h) { this->w = w; this->h = h; };
friend bool RectManager::equals(Rect r, Rect s);
};
bool RectManager::equals(Rect r, Rect s) {
if (r.w == s.w && r.h == s.h)return true;
else return false;
}
int main() {
Rect a(3, 4), b(3, 4);
RectManager man;
if (man.equals(a, b))cout << "equals" << endl;
else cout << "not equals" << endl;
}