<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: yeonseong</title>
    <description>The latest articles on Forem by yeonseong (@yeonseong).</description>
    <link>https://forem.com/yeonseong</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F774826%2F9fbebd8c-de6d-4368-83b5-832eef986e2a.jpeg</url>
      <title>Forem: yeonseong</title>
      <link>https://forem.com/yeonseong</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/yeonseong"/>
    <language>en</language>
    <item>
      <title>division operator in javascript</title>
      <dc:creator>yeonseong</dc:creator>
      <pubDate>Sat, 17 Dec 2022 16:23:13 +0000</pubDate>
      <link>https://forem.com/yeonseong/-in-javascript-1dg5</link>
      <guid>https://forem.com/yeonseong/-in-javascript-1dg5</guid>
      <description>&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="mi"&gt;42&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;is 21 of course&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="mi"&gt;42&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;is 8.4, not 8&lt;/p&gt;

&lt;p&gt;in javascript &lt;code&gt;/&lt;/code&gt; operator no discard the decimal point.&lt;/p&gt;

&lt;p&gt;you should use Math.round(), Math.ceil() or Math.floor()&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;round&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;42&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// 8&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>webdev</category>
      <category>programming</category>
    </item>
    <item>
      <title>singleton in javascript</title>
      <dc:creator>yeonseong</dc:creator>
      <pubDate>Fri, 16 Dec 2022 01:29:37 +0000</pubDate>
      <link>https://forem.com/yeonseong/singleton-in-javascript-21ik</link>
      <guid>https://forem.com/yeonseong/singleton-in-javascript-21ik</guid>
      <description>&lt;h1&gt;
  
  
  singleton in javascript
&lt;/h1&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;Singleton&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;Singleton&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;instance&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nx"&gt;Singleton&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;instance&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;Singleton&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;instance&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="nx"&gt;getInstance&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;instance&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  test
&lt;/h1&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;testA&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;Singleton&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;testB&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;Singleton&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;testA&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="nx"&gt;testB&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// true&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  singleton example (db connection)
&lt;/h1&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;URL&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;db_url&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;createConnection&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;url&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;({&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;url&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;url&lt;/span&gt;&lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;DB&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;url&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;DB&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;instance&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nx"&gt;DB&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;instance&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;createConnection&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;url&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;DB&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;instance&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="nx"&gt;connect&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;instance&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  profits of singleton
&lt;/h1&gt;

&lt;p&gt;save cost of creating instance.&lt;/p&gt;

&lt;h1&gt;
  
  
  disadvantage of singleton
&lt;/h1&gt;

&lt;p&gt;high coupling &lt;br&gt;
(can be resolved DI(dependency injection))&lt;/p&gt;

</description>
    </item>
    <item>
      <title>virtual in C++</title>
      <dc:creator>yeonseong</dc:creator>
      <pubDate>Thu, 15 Dec 2022 09:50:14 +0000</pubDate>
      <link>https://forem.com/yeonseong/virtual-in-c-2on1</link>
      <guid>https://forem.com/yeonseong/virtual-in-c-2on1</guid>
      <description>&lt;h1&gt;
  
  
  implement virtual in C++
&lt;/h1&gt;

&lt;p&gt;C++에서 클래스를 컴파일하면 그 클래스의 모든 메서드를 담은 바이너리 객체가 생성됨.&lt;/p&gt;

&lt;p&gt;컴파일러는 &lt;code&gt;virtual&lt;/code&gt;로 선언되지 않는 메서드를 호출하는 부분을 정적 바인딩(static binding)함.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;virtual&lt;/code&gt;로 선언하면 vtable이라는 특수한 메모리 영역을 활용하여 메서드를 호출함. vtable을 보고 적합한 버전의 메서드를 실행함. (동적 바인딩, dynamic binding)&lt;/p&gt;

&lt;p&gt;virtual 메서드가 하나 이상 정의도니 클래스마다 vtable이 하나씩 있고, vtable에 대한 포인터를 가짐.&lt;/p&gt;

&lt;h2&gt;
  
  
  정적바인딩(static binding)
&lt;/h2&gt;

&lt;p&gt;이른 바인딩(early binding)이라고도 함. 컴파일 시간에 바인딩이 결정되는 것&lt;/p&gt;

</description>
      <category>virtual</category>
      <category>cpp</category>
    </item>
    <item>
      <title>C style cast vs C++ style cast in C++</title>
      <dc:creator>yeonseong</dc:creator>
      <pubDate>Wed, 07 Dec 2022 10:20:00 +0000</pubDate>
      <link>https://forem.com/yeonseong/c-style-cast-vs-c-style-cast-in-c-2g3g</link>
      <guid>https://forem.com/yeonseong/c-style-cast-vs-c-style-cast-in-c-2g3g</guid>
      <description>&lt;h1&gt;
  
  
  conclusion
&lt;/h1&gt;

&lt;p&gt;&lt;strong&gt;USE C++ STYLE CAST&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;    &lt;span class="err"&gt;⭕️&lt;/span&gt; &lt;span class="k"&gt;static_cast&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;float&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;_value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; 
    &lt;span class="err"&gt;❌&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;float&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="n"&gt;_value&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h1&gt;
  
  
  reasons
&lt;/h1&gt;

&lt;ol&gt;
&lt;li&gt;C++ style cast can be check in compile time.&lt;/li&gt;
&lt;li&gt;C++ style cast is more spotted easily!&lt;/li&gt;
&lt;/ol&gt;
&lt;h1&gt;
  
  
  reference
&lt;/h1&gt;


&lt;div class="ltag__stackexchange--container"&gt;
  &lt;div class="ltag__stackexchange--title-container"&gt;
    
      &lt;div class="ltag__stackexchange--title"&gt;
        &lt;div class="ltag__stackexchange--header"&gt;
          &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--7Gn-iPj_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/stackoverflow-logo-b42691ae545e4810b105ee957979a853a696085e67e43ee14c5699cf3e890fb4.svg" alt=""&gt;
          &lt;a href="https://stackoverflow.com/questions/1609163/what-is-the-difference-between-static-cast-and-c-style-casting" rel="noopener noreferrer"&gt;
            What is the difference between static_cast&amp;lt;&amp;gt; and C style casting?
          &lt;/a&gt;
        &lt;/div&gt;
        &lt;div class="ltag__stackexchange--post-metadata"&gt;
          &lt;span&gt;Oct 22 '09&lt;/span&gt;
            &lt;span&gt;Comments: 1&lt;/span&gt;
            &lt;span&gt;Answers: 7&lt;/span&gt;
        &lt;/div&gt;
      &lt;/div&gt;
      &lt;a class="ltag__stackexchange--score-container" href="https://stackoverflow.com/questions/1609163/what-is-the-difference-between-static-cast-and-c-style-casting" rel="noopener noreferrer"&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Y9mJpuJP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/stackexchange-arrow-up-eff2e2849e67d156181d258e38802c0b57fa011f74164a7f97675ca3b6ab756b.svg" alt=""&gt;
        &lt;div class="ltag__stackexchange--score-number"&gt;
          270
        &lt;/div&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--wif5Zq3z--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/stackexchange-arrow-down-4349fac0dd932d284fab7e4dd9846f19a3710558efde0d2dfd05897f3eeb9aba.svg" alt=""&gt;
      &lt;/a&gt;
    
  &lt;/div&gt;
  &lt;div class="ltag__stackexchange--body"&gt;
    
&lt;p&gt;Is there any reason to prefer &lt;code&gt;static_cast&amp;lt;&amp;gt;&lt;/code&gt; over C style casting? Are they equivalent? Is there any sort of speed difference?&lt;/p&gt;

    
  &lt;/div&gt;
  &lt;div class="ltag__stackexchange--btn--container"&gt;
    &lt;a href="https://stackoverflow.com/questions/1609163/what-is-the-difference-between-static-cast-and-c-style-casting" class="ltag__stackexchange--btn" rel="noopener noreferrer"&gt;Open Full Question&lt;/a&gt;
  &lt;/div&gt;
&lt;/div&gt;



</description>
    </item>
    <item>
      <title>Memory layout in C++</title>
      <dc:creator>yeonseong</dc:creator>
      <pubDate>Thu, 01 Dec 2022 12:58:31 +0000</pubDate>
      <link>https://forem.com/yeonseong/memory-layout-in-c-5a12</link>
      <guid>https://forem.com/yeonseong/memory-layout-in-c-5a12</guid>
      <description>&lt;h1&gt;
  
  
  automatic storage
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;exists till the function ends.**
-&amp;gt; only useable in the scope&lt;/li&gt;
&lt;li&gt;automatic variable is variable used in function.&lt;/li&gt;
&lt;li&gt;allocated in &lt;strong&gt;stack&lt;/strong&gt;
-&amp;gt; last-in, first-out
## example in automatic storage
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kt"&gt;char&lt;/span&gt; &lt;span class="n"&gt;temp&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;42&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt; &lt;span class="c1"&gt;// this is automatic variable&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  static storage
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;exists till program ends.&lt;/li&gt;
&lt;li&gt;allocated in &lt;strong&gt;data&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  example in static storage
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="kt"&gt;char&lt;/span&gt; &lt;span class="n"&gt;temp&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;42&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt; &lt;span class="c1"&gt;// this is static variable&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  dynamic storage
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;exits till &lt;code&gt;delete&lt;/code&gt; is called.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;new&lt;/code&gt; and &lt;code&gt;delete&lt;/code&gt; operators manage memory poll (a.k.a free store)&lt;/li&gt;
&lt;li&gt;allocated in &lt;strong&gt;heap&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;depend to programmer. 

&lt;ul&gt;
&lt;li&gt;WATCH MEMORY LEAKS

&lt;ul&gt;
&lt;li&gt;recommend : locate &lt;code&gt;new&lt;/code&gt; and &lt;code&gt;delete&lt;/code&gt; close.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;/li&gt;

&lt;/ul&gt;

&lt;h2&gt;
  
  
  example in dymaic storage
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;ptr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;42&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;delete&lt;/span&gt; &lt;span class="n"&gt;ptr&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  reference
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://hackthedeveloper.com/memory-layout-c-program/" rel="noopener noreferrer"&gt;https://hackthedeveloper.com/memory-layout-c-program/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;C++ Primer Puls sixth edition(Stephen Prata)&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>watercooler</category>
    </item>
    <item>
      <title>When Constructors is called in C++</title>
      <dc:creator>yeonseong</dc:creator>
      <pubDate>Thu, 01 Dec 2022 08:49:30 +0000</pubDate>
      <link>https://forem.com/yeonseong/when-constructors-is-called-in-c-2f56</link>
      <guid>https://forem.com/yeonseong/when-constructors-is-called-in-c-2f56</guid>
      <description>&lt;h1&gt;
  
  
  Constructor
&lt;/h1&gt;

&lt;p&gt;Constructor in C++ is a special non-static member function of a class that is used to initialize objects of its class type as &lt;a href="https://en.cppreference.com/w/cpp/language/constructor" rel="noopener noreferrer"&gt;cpp reference&lt;/a&gt; say.&lt;/p&gt;

&lt;p&gt;it means Constructors dose not construct anywhere, &lt;strong&gt;Constructor is just invoked at the time of object creation.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Constructor is just &lt;strong&gt;function&lt;/strong&gt; that is invoked automatically at the time of object creation. so you can invoke other function in constructor.&lt;/p&gt;

&lt;h1&gt;
  
  
  example
&lt;/h1&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="n"&gt;ClassName&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;init&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;id_in&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// other function&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;m_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;id_in&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="n"&gt;ClassName&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;ClassName&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="c1"&gt;// constructor&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;init&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;42&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  reference
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://www.geeksforgeeks.org/constructors-c/" rel="noopener noreferrer"&gt;https://www.geeksforgeeks.org/constructors-c/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://en.cppreference.com/w/cpp/language/constructor" rel="noopener noreferrer"&gt;https://en.cppreference.com/w/cpp/language/constructor&lt;/a&gt;&lt;/p&gt;

</description>
      <category>watercooler</category>
    </item>
    <item>
      <title>why seperate hpp and cpp</title>
      <dc:creator>yeonseong</dc:creator>
      <pubDate>Tue, 29 Nov 2022 09:53:39 +0000</pubDate>
      <link>https://forem.com/yeonseong/why-seperate-hpp-and-cpp-15bc</link>
      <guid>https://forem.com/yeonseong/why-seperate-hpp-and-cpp-15bc</guid>
      <description>&lt;h3&gt;
  
  
  separating the interface from the implementation.
&lt;/h3&gt;

&lt;p&gt;The header declares "what" a class (or whatever is being implemented) will do&lt;/p&gt;

&lt;p&gt;The cpp file defines "how" it will perform those features.&lt;/p&gt;

&lt;h3&gt;
  
  
  class reusability
&lt;/h3&gt;

&lt;p&gt;other cpp file that wanna use our class, only need the interface(hpp file). &lt;/p&gt;

&lt;p&gt;if hpp file have implementation code. it will be included in other cpp file.&lt;/p&gt;

&lt;h1&gt;
  
  
  refereces
&lt;/h1&gt;


&lt;div class="ltag__stackexchange--container"&gt;
  &lt;div class="ltag__stackexchange--title-container"&gt;
    
      &lt;div class="ltag__stackexchange--title"&gt;
        &lt;div class="ltag__stackexchange--header"&gt;
          &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--7Gn-iPj_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/stackoverflow-logo-b42691ae545e4810b105ee957979a853a696085e67e43ee14c5699cf3e890fb4.svg" alt=""&gt;
          &lt;a href="https://stackoverflow.com/questions/1305947/why-does-c-need-a-separate-header-file" rel="noopener noreferrer"&gt;
            Why does C++ need a separate header file?
          &lt;/a&gt;
        &lt;/div&gt;
        &lt;div class="ltag__stackexchange--post-metadata"&gt;
          &lt;span&gt;Aug 20 '09&lt;/span&gt;
            &lt;span&gt;Comments: 2&lt;/span&gt;
            &lt;span&gt;Answers: 13&lt;/span&gt;
        &lt;/div&gt;
      &lt;/div&gt;
      &lt;a class="ltag__stackexchange--score-container" href="https://stackoverflow.com/questions/1305947/why-does-c-need-a-separate-header-file" rel="noopener noreferrer"&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Y9mJpuJP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/stackexchange-arrow-up-eff2e2849e67d156181d258e38802c0b57fa011f74164a7f97675ca3b6ab756b.svg" alt=""&gt;
        &lt;div class="ltag__stackexchange--score-number"&gt;
          195
        &lt;/div&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--wif5Zq3z--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/stackexchange-arrow-down-4349fac0dd932d284fab7e4dd9846f19a3710558efde0d2dfd05897f3eeb9aba.svg" alt=""&gt;
      &lt;/a&gt;
    
  &lt;/div&gt;
  &lt;div class="ltag__stackexchange--body"&gt;
    
&lt;p&gt;I've never really understood why C++ needs a separate header file with the same functions as in the .cpp file. It makes creating classes and refactoring them very difficult, and it adds unnecessary files to the project. And then there is the problem with having to include header files, but…&lt;/p&gt;
    
  &lt;/div&gt;
  &lt;div class="ltag__stackexchange--btn--container"&gt;
    &lt;a href="https://stackoverflow.com/questions/1305947/why-does-c-need-a-separate-header-file" class="ltag__stackexchange--btn" rel="noopener noreferrer"&gt;Open Full Question&lt;/a&gt;
  &lt;/div&gt;
&lt;/div&gt;



&lt;div class="ltag__stackexchange--container"&gt;
  &lt;div class="ltag__stackexchange--title-container"&gt;
    
      &lt;div class="ltag__stackexchange--title"&gt;
        &lt;div class="ltag__stackexchange--header"&gt;
          &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--7Gn-iPj_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/stackoverflow-logo-b42691ae545e4810b105ee957979a853a696085e67e43ee14c5699cf3e890fb4.svg" alt=""&gt;
          &lt;a href="https://stackoverflow.com/questions/333889/why-have-header-files-and-cpp-files" rel="noopener noreferrer"&gt;
            Why have header files and .cpp files?
          &lt;/a&gt;
        &lt;/div&gt;
        &lt;div class="ltag__stackexchange--post-metadata"&gt;
          &lt;span&gt;Dec  2 '08&lt;/span&gt;
            &lt;span&gt;Comments: 5&lt;/span&gt;
            &lt;span&gt;Answers: 9&lt;/span&gt;
        &lt;/div&gt;
      &lt;/div&gt;
      &lt;a class="ltag__stackexchange--score-container" href="https://stackoverflow.com/questions/333889/why-have-header-files-and-cpp-files" rel="noopener noreferrer"&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Y9mJpuJP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/stackexchange-arrow-up-eff2e2849e67d156181d258e38802c0b57fa011f74164a7f97675ca3b6ab756b.svg" alt=""&gt;
        &lt;div class="ltag__stackexchange--score-number"&gt;
          543
        &lt;/div&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--wif5Zq3z--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/stackexchange-arrow-down-4349fac0dd932d284fab7e4dd9846f19a3710558efde0d2dfd05897f3eeb9aba.svg" alt=""&gt;
      &lt;/a&gt;
    
  &lt;/div&gt;
  &lt;div class="ltag__stackexchange--body"&gt;
    
&lt;p&gt;Why does C++ have header files and .cpp files?&lt;/p&gt;

    
  &lt;/div&gt;
  &lt;div class="ltag__stackexchange--btn--container"&gt;
    &lt;a href="https://stackoverflow.com/questions/333889/why-have-header-files-and-cpp-files" class="ltag__stackexchange--btn" rel="noopener noreferrer"&gt;Open Full Question&lt;/a&gt;
  &lt;/div&gt;
&lt;/div&gt;



&lt;div class="ltag__reddit--container"&gt;
  &lt;div class="ltag__reddit--title-container"&gt;
    
      &lt;div class="ltag__reddit--title"&gt;
        &lt;h1&gt;
          &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--bCqI7Yj---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/reddit-icon-c6851eed10026b5707e2e8c814b5bbcbb4823de68d5b611a6f4b99c8beed6f05.svg" alt="Reddit Logo"&gt;
          &lt;a href="https://www.reddit.com/r/cpp/comments/lorm3s/header_only_vs_hppcpp_styles/" rel="noopener noreferrer"&gt;
            Header only vs hpp/cpp styles
          &lt;/a&gt;
        &lt;/h1&gt;
        &lt;div class="ltag__reddit--post-metadata"&gt;
          &lt;span&gt;Feb 21 '21&lt;/span&gt;
          &lt;span&gt;Author: DmitryiKh&lt;/span&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    
  &lt;/div&gt;
  &lt;div class="ltag__reddit--body"&gt;
    
&lt;p&gt;I would like to ask you about your opinion about header only style of c++ programming.&lt;/p&gt;
&lt;p&gt;I’m stick with header only approach for the next reasons:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Not repeating of functions signatures.&lt;/li&gt;
&lt;li&gt;Define class method outside of class is a boilerplate (thinking of template methods of template class)&lt;/li&gt;
&lt;li&gt;There are lot of templated c++ code that anyway needs to be placed…&lt;/li&gt;
&lt;/ol&gt;
    
  &lt;/div&gt;
  &lt;div class="ltag__reddit--btn--container"&gt;
    
      &lt;a href="https://www.reddit.com/r/cpp/comments/lorm3s/header_only_vs_hppcpp_styles/" rel="noopener noreferrer"&gt;See Full Post&lt;/a&gt;
    
  &lt;/div&gt;
&lt;/div&gt;


</description>
      <category>cpp</category>
    </item>
    <item>
      <title>'\n' vs endl in Cpp</title>
      <dc:creator>yeonseong</dc:creator>
      <pubDate>Tue, 29 Nov 2022 09:31:57 +0000</pubDate>
      <link>https://forem.com/yeonseong/n-vs-endl-in-cpp-59eh</link>
      <guid>https://forem.com/yeonseong/n-vs-endl-in-cpp-59eh</guid>
      <description>&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;cout&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="sc"&gt;'\n'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;just inserts a new line in cout buffer&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;cout&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;endl&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;inserts a new line in cout buffer, and flushes the cout buffer(a.k.a stream)&lt;/p&gt;

</description>
      <category>emptystring</category>
    </item>
    <item>
      <title>?? in Javascript -Nullish coalescing operator-</title>
      <dc:creator>yeonseong</dc:creator>
      <pubDate>Fri, 25 Nov 2022 18:22:18 +0000</pubDate>
      <link>https://forem.com/yeonseong/-in-javascript-nullish-coalescing-operator--4cgd</link>
      <guid>https://forem.com/yeonseong/-in-javascript-nullish-coalescing-operator--4cgd</guid>
      <description>&lt;h1&gt;
  
  
  ?? in javascipt
&lt;/h1&gt;

&lt;p&gt;Nullish coalescing operatior(??) is return right operand when left operand is &lt;code&gt;null&lt;/code&gt; or &lt;code&gt;undefined&lt;/code&gt;. if left operand is not nullish it return left operand.&lt;/p&gt;

&lt;h1&gt;
  
  
  example basic
&lt;/h1&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;foo&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;default string&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;foo&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="c1"&gt;// expected output: "default string"&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;bar&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="mi"&gt;42&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;bar&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="c1"&gt;// expected output: 0&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  example in react
&lt;/h1&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;who&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setWho&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;initWho&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;all&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  reference
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Nullish_coalescing" rel="noopener noreferrer"&gt;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Nullish_coalescing&lt;/a&gt;&lt;/p&gt;

</description>
      <category>career</category>
      <category>fullstack</category>
      <category>uxdesign</category>
      <category>cybersecurity</category>
    </item>
    <item>
      <title>Process meaning, Process State</title>
      <dc:creator>yeonseong</dc:creator>
      <pubDate>Thu, 24 Nov 2022 17:55:26 +0000</pubDate>
      <link>https://forem.com/yeonseong/process-meaning-3a4</link>
      <guid>https://forem.com/yeonseong/process-meaning-3a4</guid>
      <description>&lt;h1&gt;
  
  
  process meaning
&lt;/h1&gt;

&lt;p&gt;Process is the &lt;strong&gt;program in execution&lt;/strong&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  process state
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt; running : process has the CPU and executing the mechain language. &lt;/li&gt;
&lt;li&gt;ready :  can execute immediately. but no allocated CPU&lt;/li&gt;
&lt;li&gt;wating(blocked) : can not execute immediately 
&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F43cehnnseo3i31daxq9d.png" alt="Image description" width="652" height="254"&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>vscode</category>
      <category>ai</category>
      <category>tooling</category>
      <category>discuss</category>
    </item>
    <item>
      <title>storage devices hierarchy</title>
      <dc:creator>yeonseong</dc:creator>
      <pubDate>Thu, 24 Nov 2022 15:43:55 +0000</pubDate>
      <link>https://forem.com/yeonseong/storage-devices-hierarchy-b0o</link>
      <guid>https://forem.com/yeonseong/storage-devices-hierarchy-b0o</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--zHwiJJ7C--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e75a2i89cq5ejwhd1o24.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--zHwiJJ7C--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e75a2i89cq5ejwhd1o24.png" alt="Image description" width="880" height="511"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.cs.csustan.edu/~john/classes/previous_semesters/cs3750_operatingsys_i/2019_02_Spr/Notes/Chap01/01_Introduction.html"&gt;source&lt;/a&gt;&lt;/p&gt;

</description>
      <category>database</category>
      <category>computerscience</category>
    </item>
    <item>
      <title>em vs rem in css</title>
      <dc:creator>yeonseong</dc:creator>
      <pubDate>Wed, 23 Nov 2022 18:11:12 +0000</pubDate>
      <link>https://forem.com/yeonseong/em-vs-rem-in-css-2g4f</link>
      <guid>https://forem.com/yeonseong/em-vs-rem-in-css-2g4f</guid>
      <description>&lt;h1&gt;
  
  
  em
&lt;/h1&gt;

&lt;p&gt;&lt;code&gt;1em = 10px * 1&lt;/code&gt;&lt;br&gt;
the standard of em is the current element's &lt;code&gt;font-size&lt;/code&gt; in using em &lt;/p&gt;

&lt;h1&gt;
  
  
  rem
&lt;/h1&gt;

&lt;p&gt;&lt;code&gt;1rem = 10px * 1&lt;/code&gt;&lt;br&gt;
the standard of em is the root element's (&amp;lt;html&amp;gt;)  &lt;code&gt;font-size&lt;/code&gt; in using rem &lt;/p&gt;

</description>
      <category>css</category>
    </item>
  </channel>
</rss>
