1
2
3
4
5
6
7
8
9
10
11
12
#include <iostream>
#include <string>
using namespace std;
 
class Car {
    int speed;
    int gear;
    string color;
 
public:
    Car(int s = 0, int g = 1, string c = "white") : speed(s), gear(g), color(c) {}
};
cs





11번째줄이 생성자라는건 알겠는데 s = 0, g = 1, c = "white" 이걸 왜 하는건가요 ?


보통 


1
2
3
 
    Car(int s, int g, string c) : speed(s), gear(g), color(c) {}
 
cs



이렇게 하지않나요?


입력값이 없으면 0,1,white로 초기화하고 있다면 그걸로 초기화 하라는 의미인가요 ?