#include <iostream>
namespace x
{
class xy
{
private:
int x;
int y;
public:
xy() {
x = 0;
y = 0;
}
xy(int _in_x, int _in_y)
{
x = _in_x;
y = _in_y;
}
~xy() {}
int getX()
{
return x;
}
int getY()
{
return y;
}
void setX(int _in_x)
{
x = _in_x;
}
void setY(int _in_y)
{
y = _in_y;
}
};
}
int main(void)
{
x::xy s(12, 12);
std::cout << \"do not using namespace x\" << std::endl;
std::cout << s.getX() << std::endl << s.getY() << std::endl;
std::cout << std::endl << \"using namespace x\" << std::endl;
using namespace x;
xy x;
int a = 30;
int b = 60;
x.setX(a);
x.setY(b);
std::cout << x.getX() << std::endl << x.getY() << std::endl;
std::cout << std::endl << \"using std::????\" << std::endl;
using std::cout;
using std::endl;
xy y;
int c = 20;
int d = 3;
y.setX(c);
y.setY(d);
cout << y.getX() << endl << y.getY() << endl;
return 0;
}
네임스페이스 다르게 정의되어있는 헤더에서 메인으로 클래스 가져오는 방법중에
using 안쓰긔, using 네임스페이스::클래스, using namespace 네임스페이스 이렇게 3개가있네
이 3가지 방법중 뭐가 제일 낫냐?
게임실무 5년가량 뛰면서 유저단의 namespace는 단 한번도 using을 써본적이 ㅇ벗음
감사용