메뉴 바로가기 검색 및 카테고리 바로가기

한빛미디어

뇌를 자극하는 C++ 프로그래밍

뇌를 자극하는 C++ 프로그래밍 질의응답 게시판입니다.

연산자 오보로딩.... 좀 어려워요

2009-11-14

|

by

2314

// 아래 부분 자세히 설명 부탁 드립니다.

#include
using std::cout;
using std::endl;
using std::cin;

using std::ostream;  // <<== 설명 부탁합니다.
using std::istream;  // <<== 설명 부탁합니다.

#include
using std::string;

#include
using std::setw;


class phone
{
private:
        string area;  // 국번
        string exchange;  // 전화앞번호
        string line;  // 전화뒷번호
public:
        friend ostream& operator<<(ostream&, const phone&);  // <<== 설명 부탁합니다.
        friend istream& operator>>(istream&, phone&);  // <<== 설명 부탁합니다.
};


ostream& operator<<(ostream& output, const phone& number)
{
        output<<"("<         return output;  // <<== 설명 부탁합니다.
}

istream& operator>>(istream& input, phone& number)
{
        input.ignore();  // <<== 설명 부탁합니다.
        input>>setw(3)>>number.area;  // <<== 설명 부탁합니다.
        input.ignore(2);  // <<== 설명 부탁합니다.
        input>>setw(3)>>number.exchange;  // <<== 설명 부탁합니다.
        input.ignore();  // <<== 설명 부탁합니다.
        input>>setw(4)>>number.line;  // <<== 설명 부탁합니다.
        return input;  // <<== 설명 부탁합니다.
}


void main()
{
        phone p;
        cin>>p; // <<== 설명 부탁합니다.(입력방법)
        cout< }
댓글 입력