{"id":383,"date":"2015-10-13T01:19:45","date_gmt":"2015-10-12T16:19:45","guid":{"rendered":"http:\/\/csharp.ihavenomoney.co.kr\/?p=383"},"modified":"2019-06-27T10:26:22","modified_gmt":"2019-06-27T01:26:22","slug":"c-basic-skills-lesson-27-templates","status":"publish","type":"post","link":"https:\/\/csharp.ihavenomoney.co.kr\/?p=383","title":{"rendered":"C++ Basic Skills: Lesson 27 &#8220;Templates&#8221;"},"content":{"rendered":"<p><iframe loading=\"lazy\" width=\"560\" height=\"315\" src=\"https:\/\/www.youtube.com\/embed\/BwOQqqRwgpA\" frameborder=\"0\" allowfullscreen><\/iframe><\/p>\n<pre class=\"lang:c++ decode:true \" >#include &lt;iostream&gt;\r\nusing namespace std;\r\n\r\ntemplate &lt;class T&gt;\r\nvoid swap_these(T &amp; a, T &amp; b)\r\n{\r\n    T a_old = a;\r\n    a = b;\r\n    b = a_old;\r\n}\r\n\r\nint main()\r\n{\r\n    int array[5] ={1,2,3,5,4};\r\n    swap_these(array[3], array[4]);\r\n    for(int i=0;i&lt;5;i++)\r\n    {\r\n        cout &lt;&lt; array[i] &lt;&lt; endl;\r\n    }\r\nreturn 0;\r\n}<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>#include &lt;iostream&gt; using namespace std; template &lt;class T&gt; void swap_these(T &amp; a, T &amp; b) { T a_old = a; a = b; b = a_old; } int main() { int array[5] ={1,2,3,5,4}; swap_these(array[3], array[4]); for(int i=0;i&lt;5;i++) { cout &lt;&lt; array[i] &lt;&lt; endl; } return 0; }<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[22],"tags":[],"class_list":["post-383","post","type-post","status-publish","format-standard","hentry","category-c"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/383","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=383"}],"version-history":[{"count":2,"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/383\/revisions"}],"predecessor-version":[{"id":530,"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/383\/revisions\/530"}],"wp:attachment":[{"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=383"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=383"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=383"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}