<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>OOP on Cheat Sheet</title><link>/kr/tags/oop/</link><description>Recent content in OOP on Cheat Sheet</description><generator>Hugo</generator><language>kr</language><atom:link href="/kr/tags/oop/index.xml" rel="self" type="application/rss+xml"/><item><title>Classes</title><link>/kr/programming/cpp/primer/classes/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>/kr/programming/cpp/primer/classes/</guid><description>&lt;h1 id="classes"&gt;Classes&lt;a class="anchor" href="#classes"&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;&lt;em&gt;C++ Primer, 5th ed.&lt;/em&gt; 7장 (Classes)을 바탕으로 정리한다.&lt;/p&gt;
&lt;h2 id="1-member-functions-and-the-implicit-this-pointer"&gt;1. Member Functions and the Implicit &lt;code&gt;this&lt;/code&gt; Pointer&lt;a class="anchor" href="#1-member-functions-and-the-implicit-this-pointer"&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;member 함수는 자신을 호출한 객체에 접근하기 위해 &lt;strong&gt;&lt;code&gt;this&lt;/code&gt;라는 숨겨진 암시적 매개변수&lt;/strong&gt;(Implicit Parameter)를 추가로 전달받는다.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;this&lt;/code&gt;는 항상 호출된 대상 객체(&amp;ldquo;이 객체&amp;rdquo;)만을 가리켜야 하므로, 개발자가 임의로 &lt;code&gt;this&lt;/code&gt;라는 이름의 매개변수나 변수를 정의하는 것은 금지되어 있으며 &lt;code&gt;this&lt;/code&gt; 자체는 주소를 바꿀 수 없는 상수 포인터다 (&lt;code&gt;CLASS *const this&lt;/code&gt;).&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="const-member-functions"&gt;&lt;code&gt;const&lt;/code&gt; Member Functions&lt;a class="anchor" href="#const-member-functions"&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;const&lt;/code&gt; member 함수&lt;/strong&gt;(매개변수 소괄호 &lt;code&gt;()&lt;/code&gt; 뒤에 &lt;code&gt;const&lt;/code&gt;가 붙은 member 함수, 예: &lt;code&gt;void bar() const&lt;/code&gt;)는 암시적 &lt;code&gt;this&lt;/code&gt; 포인터의 타입을 &lt;code&gt;const CLASS *const this&lt;/code&gt;로 만들어 호출 대상 객체의 member를 변경할 수 없도록 한다.&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="background-color:#f7f7f7;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-cpp" data-lang="cpp"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#cf222e"&gt;void&lt;/span&gt; Foo&lt;span style="color:#0550ae"&gt;::&lt;/span&gt;bar&lt;span style="color:#1f2328"&gt;();&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#57606a"&gt;// 내부적으로는 bar(Foo *const this);
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#cf222e"&gt;void&lt;/span&gt; Foo&lt;span style="color:#0550ae"&gt;::&lt;/span&gt;bar&lt;span style="color:#1f2328"&gt;()&lt;/span&gt; &lt;span style="color:#cf222e"&gt;const&lt;/span&gt;&lt;span style="color:#1f2328"&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#57606a"&gt;// 내부적으로는 bar(const Foo *const this);
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h4 id="const-int-bar-vs-int-bar-const-비교"&gt;&lt;code&gt;const int bar();&lt;/code&gt; vs. &lt;code&gt;int bar() const;&lt;/code&gt; 비교&lt;a class="anchor" href="#const-int-bar-vs-int-bar-const-%eb%b9%84%ea%b5%90"&gt;#&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;&lt;code&gt;const&lt;/code&gt;의 위치에 따라 상수성이 적용되는 대상이 완전히 다르다:&lt;/p&gt;</description></item><item><title>Object-Oriented Programming (OOP)</title><link>/kr/programming/cpp/primer/oop/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>/kr/programming/cpp/primer/oop/</guid><description>&lt;h1 id="object-oriented-programming-oop"&gt;Object-Oriented Programming (OOP)&lt;a class="anchor" href="#object-oriented-programming-oop"&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;&lt;em&gt;C++ Primer, 5th ed.&lt;/em&gt; 15장 Object-Oriented Programming 및 19.2.1절 &lt;code&gt;dynamic_cast&lt;/code&gt;를 바탕으로 OOP의 3대 핵심 원리, &lt;strong&gt;Upcast / Downcast, Object Slicing 및 다형성 컨테이너&lt;/strong&gt;, &lt;strong&gt;Virtual Function&lt;/strong&gt; (&lt;code&gt;virtual&lt;/code&gt;, &lt;code&gt;override&lt;/code&gt;, &lt;code&gt;final&lt;/code&gt;), &lt;strong&gt;Pure Virtual Function&lt;/strong&gt; (&lt;code&gt;= 0&lt;/code&gt;)과 &lt;strong&gt;Abstract Base Class&lt;/strong&gt;, 그리고 상속에서의 접근 제어를 정리한다.&lt;/p&gt;
&lt;h2 id="1-oop의-3대-핵심-개념"&gt;1. OOP의 3대 핵심 개념&lt;a class="anchor" href="#1-oop%ec%9d%98-3%eb%8c%80-%ed%95%b5%ec%8b%ac-%ea%b0%9c%eb%85%90"&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;OOP는 다음 세 가지 핵심 개념 위에 구축된다:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Data Abstraction:&lt;/strong&gt; Define classes that separate interface from implementation. — &lt;a href="../../../kr/programming/cpp/primer/classes/"&gt;Classes&lt;/a&gt; 참조&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Inheritance:&lt;/strong&gt; Define classes that model the relationships among similar types.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Dynamic Binding:&lt;/strong&gt; Use objects of derived types while ignoring the details of how they differ.&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;h2 id="2-upcast-vs-downcast와-static--dynamic-type"&gt;2. Upcast vs. Downcast와 Static / Dynamic Type&lt;a class="anchor" href="#2-upcast-vs-downcast%ec%99%80-static--dynamic-type"&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;다형성을 다루는 표현식에서는 두 가지 타입을 항상 구분해야 한다:&lt;/p&gt;</description></item></channel></rss>