ANSI C++μ λν μ½κ°μ μμ€μλ λ΄μ©μ λ€λ£¨λ μ±
. EffectiveC++ μ μΆκ°μ μΈ λ΄μ©μ΄λ€.
1. μκ° ¶
- wowbook μΈμ©
- ANSI C++μ λν μ λ°μ μΈ λ΄μ©μ κΉλν νμ²΄λ‘ μ½κ² μ½κ² λ€λ£¨κ³ μλ€. λͺ
νν κ°λ
μ€λͺ
μ΄ λ보μΈλ€. νλ‘κ·Έλ¨κ³Ό λμμΈ λ₯λ ₯μ ν₯μμν€λ 35κ°μ λ°©λ²μ΄ μ μλμ΄ μλ€. λ°°μΉ, κ°μ μμ±μ, ν¬μΈν° λ νΌλ°μ€ μΉ΄μ΄ν
, νλ½μ ν΄λμ€, λλΈ λμ€ν¨μΉμ κ°μ C++μ λ³΄λ€ μΈλ ¨λ κΈ°μ μ λν΄ μ€λͺ
νκ³ μλ€.
- μ΄ μ±
μ μ£Όμ λ΄μ©
~cpp - ν¬μΈν°μ λ νΌλ°μ€μμ μ°¨μ΄ - C++ μ€νμΌ μΊμ€νΈ - λΆνμν λν΄νΈ ꡬμ±μλ μ μΈ - μ¬μ©μ μ μμ λ³ν ν¨μ μ¬μ© - μ¦κ° μ°μ°μμ κ°μ μ°μ°μμ μ μμ νμ ννμ κ΅¬λ³ - newμ deleteμ μλ―Έ μ°¨μ΄ - μμ λλΉλ₯Ό λ§κΈ°μν μλ©Έμ μ¬μ© - μμ±μμ μμ λλΉλ₯Ό λ§μ - κ°μ ν¨μ νΈμΆκ³Ό νλΌλ―Έν° ν¨μ€μ μ°¨μ΄ μ΄ν΄ - λ νΌλ°μ€λ₯Ό μ΄μ©ν μμΈμν© μΊμ·¨ - μμΈμν© λͺ νν μ¬μ© - μμΈμν© νΈλ€λ§ λΉμ© μ΄ν΄ - 20/80 λ²μΉ - μμλ κ³μ° λΉμ© μ²μ° - μμ κ°μ²΄μ λ°μ μ΄ν΄ - κ°μ ν¨μ λΉμ©, λ€μ€ κ³μΉ, κ°μ λ² μ΄μ€ ν΄λμ€μ RTTI - ꡬ쑰체 κ°μν - ν΄λμ€ κ°μ²΄μμ μ ν - ν λ² μ΄μ€ κ°μ²΄ μꡬμ κΈμ§ - μ€λ§νΈ ν¬μΈν° - λ νΌλ°μ€ μΉ΄μ΄ν - νλ½μ ν΄λμ€ - νλ μ΄μμ κ°μ²΄μ λν κ°μ ν¨μ μμ± - ν₯ν νλ‘κ·Έλ¨ - 리νκ° μλ ν΄λμ€ μΆμ μμ± - λμΌ νλ‘κ·Έλ¨μμμ C++κ³Ό Cμ κ²°ν©
2. Project About That ¶
- μμ±μ:λ₯μλ―Ό(neocoin)
- More Effective C++ μ μμ½
- λͺ©ν: μλ£λ‘ μ΄μ© ν μ μμ μ λμ μ 보 μ λ¬
- μ§ν μΌμ
μμ 2002.01.14 μλ° μ μ§ λ³΄μλ‘ μμ λ³΄λ€ λ¦κ² μμ μ²μ λͺ©ν 2002.01.31 18μ₯ μ’ λ£ 1μ°¨ μ°κΈ° 2002.02.15 28μ₯ μ’ λ£ 2μ°¨ μ°κΈ° 2002.02.28 32μ₯ μ’ λ£ 3μ°¨ μ°κΈ° 2002.03.08 35μ₯ μ’ λ£ - . 2002.03.21 μ΅μ’
κΈ°λ‘ :
- μμλ₯Ό 보μΈμ. 보μλ€ μ΄μν λΆλΆλ§ κ°μ΄ μκ°μ.
- μ΄ λ¬Έμλ ZeroPage νμλ€μ μν λ΄λΆ λ¬Έμμ
λλ€. νμ μ΄μΈμ μ μκΆ λ¬Έμ μ μμ§κ° λλ λ¬Έμ μ κ΄ν΄μ μ±
μμ μ§μ μμ΅λλ€.
- μκ°μ΄ μμΌλ, μ°¨ν λ¬Έμλ₯Ό λ€μ λ€λ¬λ κ²μ 2002λ
μ¬λ¦ λ°©νμ€μ ν μκ°μ
λλ€.
- μμλ₯Ό 보μΈμ. 보μλ€ μ΄μν λΆλΆλ§ κ°μ΄ μκ°μ.
2.1.1. Basic ¶
MoreEffectiveC++/Basic S
- Item 1: Distinguish between pointers and references. - Pointerμ Referenceꡬλ³ν΄λΌ.
- Item 2: Prefer C++ style casts.- μ€νμΌμ νλ³νμ κΆμ₯νλ€.
- Item 3: Never treat arrays polymorphically - μ λλ‘! ν΄λμ€ κ°μ λ€νμ±μ ν΅ν λ°°μ΄ μ·¨κΈμ νμ§ λ§λΌ
- Item 4: Avoid gratuitous default constructors. - μμμ μΌλ‘ μ 곡λλ κΈ°λ³Έ μμ±μλ₯Ό νΌνλΌ. νΉμ κΈ°λ³Έ μμ±μμ λͺ¨νΈμ±μ νμ
νλΌ.
2.1.2. Operator ¶
MoreEffectiveC++/Operator S
- Item 5: Be wary of user-defined conversion functions. - μ¬μ©μ μ μ νλ³ν(conversion) ν¨μμ μ£ΌμνλΌ!
- Item 6: Distinguish between prefix and postfix forms of increment and decrement operators. - prefixμ postfixλ‘μ μ¦κ° μ°μ°μ ꡬλΆνλΌ!
- Item 7: Never overload &&, ||, or ,. - μ λλ‘! &&, ||, ',' μ΄ μ°μ°μλ€μ overload νμ§ λ§μλΌ
- Item 8: Understand the differend meanings of new and delete - newμ deleteκ° μ°μμ λ°λ₯Έ μλ―Έλ€μ μ°¨μ΄λ₯Ό μ΄ν΄νλΌ.
2.1.3. Exception ¶
MoreEffectiveC++/Exception, S before 12
- Item 9: Use destuctors to prevent resource leaks. - μμμ΄ μλκ±Έ λ§λ νκ΄΄μλ₯Ό μ¬μ©ν΄λΌ.
- Item 10: Prevent resource leaks in constructors. - μμ±μμμ μμμ΄ μΈλκ±Έ λ§μλΌ.
- Item 11: Prevent exception from leaving destuctors. - νκ΄΄μλ‘ λΆν°μ μμΈ μ²λ¦¬λ₯Ό λ§μλΌ.
- Item 12: Understand how throwing an exception differs from passing a parameter or calling a virtual function
- κ°μ ν¨μ λΆλ₯΄κΈ°λ, μΈμ μ λ¬λ‘ μ²λ¦¬μ μμΈμ λ¬μ λ°©λ²μ μ°¨μ΄μ μ μ΄ν΄νλΌ.
- Item 13: Catch exception by reference - μμΈλ μ°Έμ‘°(reference)λ‘ μ‘μλΌ.
- Item 14: Use exception specifications judiciously. - μμΈλ₯Ό μ μ€νκ² μ¬μ©νλΌ.
- Item 15: Understand the costs of exception handling. - μμΈ νΈλ€λ§μ λν λΉμ© μ§λΆ λν μ΄ν΄
2.1.4. Efficiency ¶
MoreEffectiveC++/Efficiency, T
- Item 16: Remember the 80-20 rule. - 80-20 κ·μΉμ κΈ°μ΅ν΄λΌ.
- Item 17: Consider using lazy evaluation - lazy evaluationμ μ°μμ λνμ¬ μκ°ν΄ 보μ.
- Item 18: Amortize the cose of expected computations. - μμλλ μ°μ°μ κ°μ κ³μ°ν΄ λμ΄λΌ.
- Item 19: Understand the orgin of temporary objects.- μμ κ°μ²΄λ€μ κΈ°λ³Έμ μ΄ν΄νμ.
- Item 20: Facilitate the return value optimization - λ°νλλ κ°μ μ΅μ ν νλΌ
- Item 21: Overload to avoid implicit type conversions.- μμμ (implicit) νλ³νμ overloadλ₯Ό νΌνλΌ
- Item 22: Consider using op= instead of stand-alone op.- νΌμ μ°μ΄λ op(+,-,/) λμ μ op=(+=,-=,/=)μ μ°λκ±Έ μκ°ν΄ λ΄λΌ.
- Item 23: Consider alternative libraries. - λΌμ΄λΈλ¬λ¦¬ κ΅μ²΄μ κ΄ν΄μ μκ°ν΄ λ΄λΌ.
- Item 24: Understand the costs of virtual functions, multiple ingeritance, virtual base classes, and RTTI
- κ°μ ν¨μ, λ€μ€ μμ, κ°μ κΈ°μ΄ ν΄λμ€, RTTI(μ€μκ° ν κ²μ¬)μ λν λΉμ©μ μ΄ν΄νλΌ
2.1.5. Techniques1of2 ¶
MoreEffectiveC++/Techniques1of3, S or T
- Item 25: Virtualizing constructors and non-member functions. - μμ±μμ λΉλ©€λ² ν¨μλ₯Ό κ°μμΌλ‘ λμκ°κ² νκΈ°.
- Item 26: Limiting the number of objects of a class - κ°μ²΄ μ«μ μ ννκΈ°.
- Item 27: Requiring or prohibiting heap-based objects. - Heapμμμ μ¬μ©νλ κ°μ²΄ μꡬνκΈ° or νΌνκΈ°.
- Item 28: Smart pointers - λλν ν¬μΈν°:μ€λ§νΈ ν¬μΈν°
2.1.6. Techniques2of2 ¶
MoreEffectiveC++/Techniques2of3, T
- Item 29: Reference counting - μ°Έμ‘° μΈκΈ°
- Item 30: Proxy - λ리μ
2.1.7. Techniques2of2 ¶
MoreEffectiveC++/Techniques3of3, T
- Item 31: Making functions virtual with respect to more than one object. - νλ μ΄μ κ°μ²΄μ λμνλ ν¨μλ₯Ό virtual(κ°μ)μΌλ‘ λμ μν€κΈ°
2.1.8. Miscellany ¶
MoreEffectiveC++/Miscellany T
- Item 32: Program in the Future tense - λ―Έλλ₯Ό λλΉνλ νλ‘κ·Έλ¨
- Item 33: Make non-leaf classes abstract. - μ λλ ν΄λμ€κ° μλ μνμ ν΄λμ€λ‘ μΆμν νλΌ.
- Item 34: Understand how to combine C++ and C in the same program. - κ°μ νλ‘κ·Έλ¨μμ C++μ Cλ₯Ό νΌν©νλ λ² μ΄ν΄ν΄λΌ.
- Item 35: Familiarize yourself with Β°the language standard. - μΈμ΄ νμ€μ μΉν΄μ ΈλΌ.
2.1.9. Appendix ¶
MoreEffectiveC++/Appendix : νκΈνμ νμμ±μ λͺ»λλΌλ©°, μν€νλ§ μμΌλμ
- Recommended Reading
- An auto_ptr Implementation
2.3. Log ¶
- 2002.02.09 λ³Όμλ‘ μ μ€ν λ΄μ© ν¬μ±μ΄ μ΄λ€. Efficiencyμ λΆλΆμ΄ κ°μ₯ μ€μνλ€κ³ λ½μλλ°, λ€μ Technicque ννΈλ Efficiencyλ₯Ό λΉμκ³ μλ€. κ° μ₯λ§λ€ κ±°μ λμΈλ°°μ λ€λΌλ μκ³Ό λλΆμ΄, "C++μμ μκ³ μΆμλ κ²μ΄ μ¬κΈ° λ€ λͺ¨μ¬ μꡬλ" νλ μκ°μ΄ λ λ€. λ΄μ©μ΄ λ무 λ§μμ μ΄μ©μ μμ΄ λ€μ μμ½ μ²΄μ λ‘ κ°μΌ κ² λ€.
- 2002.02.15 λλμ΄ μ€λ§νΈ ν¬μΈν°λ₯Ό μ€λͺ
ν μ μλ skillμ νλνλ€. λ€μμ Reference counting μ€λͺ
skillμ νλν΄μΌ νλ€. Reference countingμ COMκΈ°μ μ κ·Όκ°μ΄ λκ³ μμΌλ©°, κ³Όκ±° Java VMμμ Garbage collectionμ μνν λ μ¬μ©νλ€κ³ μκ³ μλ€. λ¬Όλ‘ νμ¬λ Java Garbage Collectorλ CLRμ΄λ Tracingμ μ·¨νκ³ μλ κ²μΌλ‘ μκ³ μλ€. μ. μ€λμ΄ νλ‘μ νΈ λ§μ§λ§ μμ μΌλ‘ μ‘μ λ μΈλ°, λμ ν λΆκ°λ₯νκ³ , μ€λ ν¬κΈ°νκΈ°μλ λ€μ λ΄μ©λ€μ΄ λ무 λ§€λ ₯μλ€. μΉΌμ λ½μμΌλ μ΄λ²λ¬ μμΌλ‘λ λμ₯μ λ³Έλ€.
- 2002.02.17 Reference Counting μ€λͺ
μ€ν¬ νλ. μ΄μ κΉμ§μ€ κ°μ₯ λ°©λν λΆλμ΄κ³ , μ΄μ±
μ λ€λ₯Έ μ΄λ¦μ΄ More Difficult C++ λΌλ κ²μ 100% 곡κ°νκ² λ§λ λ€. Techniquesκ° λ무 κΈΈμ΄μ 1of2, 2of2 μ΄λ κ² λλ‘ μͺΌκ° λ€. (μΈκ°λ‘ μͺΌκ°€μ§λ λͺ¨λ₯Έλ€.) μ²μμλ μ¬λ―Έλ‘ μμνλλ°, μμ¦μ μμμ μ ννκ³ , λ°₯ λ¨ΉμΌλ¬κ°μΌμ§. μ΄μ 7κ°(λΆλ‘κΉμ§) λ¨μλ€.
- 2002.02.24 31μ₯μ΄ μ΄μ 2μ₯ μ λ λ°μ λ¨μ§ μμλ€. μ΄λ²μ£Όλ μ΄λ°μΌ μ λ°μΌ νκ³λλ©΄μ λͺ»νλ€κ³ μμνλλ°, μ λ§ μ°Ήμ°Ήνλ€. κ±°μ 4μΌ μ λ μ§μ²΄λκ³ μμΌλ. λ€μ λ§μμ κ°λ€λ¬μ λ΄μΌ μλ£ν΄μΌμ§.
- 2002.02.25 31μ₯ μ’
λ£. μ΄μ μ΄μ±
μ ν΅μ¬λ€μ λμ΄ λλ―.
- 2002.03.02 33μ₯ μ΄μ μ’
λ£. μ§μ μμ μ’μ νμ§ μμΌλ¦¬.
- 2002.03.04 34μ₯ μ΄μ μ’
λ£
- 2002.03.08 λ¬Έμν μ’
λ£ ( 1~35μ₯ νκΈν or μμ½, Appendixμ indexλ μ μΈ)
- μ, λλμ΄ λμ΄λ€. μ¬μ€ μ§μ§ λ²μμ²λΌ λμ λ³Όλ €λ©΄ auto_ptrκ³Ό Recommended Readingμ ν΄μν΄μΌ νκ² μ§λ§ λ΄λ§μμ΄λ€. λ μ΄μ λ΄μ©μ΄ μλ€κ³ νλ©΄ λ§μ κΉλ. ν΄. μλ νλ¬μ λ μ£½μ΄λΌ λ§€λ¬λ € λλΌλ €κ³ νκ²μ νλ¬ λ° μ’ λκ²Όλ€. (2μμ 28μΌκΉμ§λ λ§μ΄λ€. ^^;;) μ΄μ μ΄λ₯Ό λ°νμΌλ‘ν μΈλ―Έλ μλ£λ§μ΄ λ¨μꡬλ. 1νκΈ°κ° λλκ³ λ°©νλ λ€μ νλ² λ§μΆ€λ²μ΄λ κ³ μΉκ³ μΆμ λ΄μ©μ κ³ μΉ κ²μ΄λ€. 보λμ°¬ ν루λ€.
- μ, λλμ΄ λμ΄λ€. μ¬μ€ μ§μ§ λ²μμ²λΌ λμ λ³Όλ €λ©΄ auto_ptrκ³Ό Recommended Readingμ ν΄μν΄μΌ νκ² μ§λ§ λ΄λ§μμ΄λ€. λ μ΄μ λ΄μ©μ΄ μλ€κ³ νλ©΄ λ§μ κΉλ. ν΄. μλ νλ¬μ λ μ£½μ΄λΌ λ§€λ¬λ € λλΌλ €κ³ νκ²μ νλ¬ λ° μ’ λκ²Όλ€. (2μμ 28μΌκΉμ§λ λ§μ΄λ€. ^^;;) μ΄μ μ΄λ₯Ό λ°νμΌλ‘ν μΈλ―Έλ μλ£λ§μ΄ λ¨μꡬλ. 1νκΈ°κ° λλκ³ λ°©νλ λ€μ νλ² λ§μΆ€λ²μ΄λ κ³ μΉκ³ μΆμ λ΄μ©μ κ³ μΉ κ²μ΄λ€. 보λμ°¬ ν루λ€.