목차
교환법칙해결하기
cout, cin 그리고 endl의 비밀
인덱스 연산자
대입 연산자 오버로딩
cout, cin 그리고 endl의 비밀
인덱스 연산자
대입 연산자 오버로딩
본문내용
#include
namespace mystd //mystd라는 이름공간 시작
{
char* endl="\n";
class ostream // 클래스 ostream 정의
{
public:
ostream& operator<<(char * str) {
printf("%s", str);
return *this;
}
ostream& operator<<(int i) {
printf("%d", i);
return *this;
}
ostream& operator<<(double i) {
printf("%e", i);
return *this;
}
};
ostream cout; //ostream 객체 생성
} // mystd 이름공간 끝
namespace mystd //mystd라는 이름공간 시작
{
char* endl="\n";
class ostream // 클래스 ostream 정의
{
public:
ostream& operator<<(char * str) {
printf("%s", str);
return *this;
}
ostream& operator<<(int i) {
printf("%d", i);
return *this;
}
ostream& operator<<(double i) {
printf("%e", i);
return *this;
}
};
ostream cout; //ostream 객체 생성
} // mystd 이름공간 끝
소개글