cpp_class_fn - 8BitsCoding/RobotMentor GitHub Wiki

  • ์ดˆ๊ธฐํ™” ๋ฆฌ์ŠคํŠธ
    • ๋ฉค๋ฒ„ ๋ณ€์ˆ˜๋ฅผ ๋Œ€์ž… ์—†์ด ์ดˆ๊ธฐํ™”
    • ์ƒ์ˆ˜๋‚˜ ์ฐธ์กฐ ๋ณ€์ˆ˜๋„ ์ดˆ๊ธฐํ™” ๊ฐ€๋Šฅ
// Example
class X {
      const int mNameSize;
      AnotherClass& mAnother;
      X(AnotherClass& another) :
          mNameSize(20),
          mAnother(another) {}
}

// ํ‹€๋ฆฐ์˜ˆ๋ฅผ ๋ณด์ž
class X {
      const int mNameSize;
      AnotherClass& mAnother;
      X(AnotherClass& another){
          mNameSize = 20;     // Error 
          mAnother = another; // Error
  }
}