#include <iostream>
using namespace std;
// 초기화리스트이야기..( Member Initialize List )
// 1. 초기화리스트모양. 특징( 대입이아닌진짜초기화이다. )
// 2. 멤버가놓여있는순서대로초기화한다.
// 3. 상수멤버와레퍼런스멤버는반드시초기화리스트로초기화해야한다.
// 4. 기본생성자가없는클래스를멤버로가질떄반드시초기화리스트를사용해서초기화해야한다.
class Point
{
        int x;
        int y;
public:
        Point( int a, int b ) : x(a), y(b)
        {
        }
};
class Rect
{
        Point p1;
        Point p2;
public:
        Rect() : p1(0, 0), p2(0, 0)
        {}
};
void main()
{
        Rect r;
        //Point p1;                   // error. 기본생성자가없다.
        Point p2( 1, 2 );      // Ok. 인자2개생성자는있다.
}
/*
class Point
{
public:
        int x;
        int y;
        const int c1;
//      int c = 0;     //error 아직c가메모리에있는게아니다.
                              // 객체를만들어야c는메모리에있다.
public:
        Point() : x(0), y(0), c1(0)           // 초기화
        {
               //x = 0;       // 대입
               //y = 0;
        }
};
void main()
{
//      const int c;   // error 초기값이필요.
        Point p;
        cout << p.x << endl;
        cout << p.y << endl;   // 10
        int a;  // a가객체라면생성자호출
        a = 0;  // 대입연산자가호출.
        int b = 0;     // 초기화. 생성자만1번호출된다.
}
*/