#include
using namespace std;
class Point {
private:
int x;
int y;
public:
bool InitMembersPoint(int xpos, int ypos);
int GetX() const;
int GetY() const;
bool SetX(int xpos);
bool SetY(int ypos);
};
bool Point::InitMembersPoint(int xpos, int ypos) {
if (0 > xpos || xpos > 100 || 0 > ypos || ypos > 100) {
cout << "벗어난 범위의 값 전달" <
return false;
}
x = xpos;
y = ypos;
return true;
}
int Point::GetX() const {
return Point::x;
}
int Point::GetY() const {
return Point::y;
}
bool Point::SetX(int xpos) {
if (0 > xpos || xpos > 100) {
cout << "벗어난 범위의 값 전달" <
return false;
}
x = xpos;
return true;
}
bool Point::SetY(int ypos) {
if (0 > ypos || ypos > 100) {
cout << "벗어난 범위의 값 전달" <
return false;
}
y = ypos;
return true;
}
------------ 위에가 Point.cpp
#include "Point.cpp"
class Rectangle {
private:
Point upLeft;
Point lowRight;
public:
bool InitMembers(const Point& ul, const Point& lr);
void ShowRecInfo() const;
};
bool Rectangle::InitMembers(const Point& ul, const Point& lr) {
if (ul.GetX() > lr.GetX() || ul.GetY() > lr.GetY()) {
cout << "잘못된 위치정보 전달" <
return false;
}
upLeft = ul;
lowRight = lr;
return true;
}
void Rectangle::ShowRecInfo() const {
cout << "Up Left: " <
cout << "lowRight: " <
}
--------------- 이게 Rectangle.cpp 인데 Point.cpp를 호출해야함
#include "Rectangle.cpp"
int main(void) {
Point p1, p2;
p1.InitMembersPoint(3, 5);
p2.InitMembersPoint(5, 11);
Rectangle rec;
rec.InitMembers(p1, p2);
rec.ShowRecInfo();
return 0;
}
이게 main함수가 있는 cpp.
cpp 이름같은건 다 정해진 과제대로 쓴거임
뭔 버그인지 몰겄는데 맨위에 #include <iostream>인데 iostream이 짤려서 안나오네요;
뭐야 복붙해서 올린건데 왤케 다 짤려서나옴???? 막 코드가 그대로 복사가 안되는데요?
디시가 디시했는데 문제라도?
https://nanikit.github.io/dc-highlighter/
여기쓰고 밑에 복붙해
근데 짤린 부분이 딱히 중요하진 않음. 막 endl; 이런게 짤림