{"id":492,"date":"2020-05-01T14:57:42","date_gmt":"2020-05-01T05:57:42","guid":{"rendered":"http:\/\/batmask.dothome.co.kr\/?p=492"},"modified":"2020-05-01T14:57:42","modified_gmt":"2020-05-01T05:57:42","slug":"oop-constructor-and-inheritance","status":"publish","type":"post","link":"http:\/\/batmask.net\/index.php\/2020\/05\/01\/492\/","title":{"rendered":"OOP: constructor and inheritance"},"content":{"rendered":"\n<p>\uc0c1\uc18d\uacfc \uad00\ub828\ud574\uc11c \uc0dd\uc131\uc790\ub294 \uc5b4\ub5bb\uac8c \uc5f0\uacb0\uc774 \ub418\ub294\uc9c0 \ud5f7\uac08\ub9b4\ub9cc\ud55c \ud3ec\uc778\ud2b8\ub4e4\uc774 \uc788\uc5b4 \ud55c \ubc88 \uc815\ub9ac\ud574 \ub193\ub294\ub2e4.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Kotlin<\/h3>\n\n\n\n<p>\ucf54\ud2c0\ub9b0\uc740 \uc0dd\uc131\uc790\uc5d0 \ud074\ub798\uc2a4\uc774\ub984\uc744 \uc4f0\uc9c0\uc54a\uace0 &#8216;constructor&#8217;\ub77c\ub294 \ud0a4\uc6cc\ub4dc\ub97c \uc4f4\ub2e4. \uc5ec\ub7ec \uc0dd\uc131\uc790\ub97c \uac00\uc9c8 \uc218 \uc788\uc73c\ub098, primary constructor\ub294 \ud074\ub798\uc2a4 \uccab \ub77c\uc778\uc744 \ud65c\uc6a9\ud55c\ub2e4. ( <a href=\"https:\/\/kotlinlang.org\/docs\/reference\/classes.html\">Kotlin \uacf5\uc2dd\ubb38\uc11c \ucc38\uc870<\/a> ) <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"kotlin\" class=\"language-kotlin\">class Person constructor(firstName: String) { \/*...*\/ }\nclass Person(firstName: String) { \/*...*\/ }\nclass Person(var firstName: String) { \/*...*\/ }<\/code><\/pre>\n\n\n\n<p>\ub450\ubc88\uc9f8 \ub77c\uc778\ucc98\ub7fc \ud0a4\uc6cc\ub4dc\ub97c \uc548\uc368\uc918\ub3c4 \ub41c\ub2e4. \ub610\ud55c, \uc138\ubc88\uc9f8\ucc98\ub7fc class property\uc815\uc758\ub97c \uc368\uc11c \ucd94\uac00\uc801\uc778 \ud560\ub2f9\ucf54\ub4dc\uc5c6\uc774 \uac04\ub2e8\ud558\uac8c \uc0ac\uc6a9\ub3c4 \uac00\ub2a5\ud558\ub2e4. <br>\uc870\uae08 \ub2f9\ud669\uc2a4\ub7ec\uc6b8 \uc218 \uc788\ub294 \uc810\uc740 \uc0dd\uc131\uc790\uc758 \ubc14\ub514\ube14\ub7ed\uc774 \uc5c6\ub2e4\ub294 \uc810\uc778\ub370, \ub2e8\uc21c\ud55c \uac12\uc758 \ucd08\uae30\ud654\ub294 \ubcc4\ub3c4\uc758 \ud45c\uc2dc\uc5c6\uc774 \ud074\ub798\uc2a4 \uba64\ubc84\ubcc0\uc218 \uc815\uc758\uc5d0\uc11c \uc0dd\uc131\uc790\ub85c \ub118\uc5b4\uc628 \uac12\uc744 \uc0ac\uc6a9\ud560 \uc218 \uc788\ub2e4. \ucd94\uac00\ub85c \uc2e4\ud589\ud574\uc57c \ud560 \ucf54\ub4dc\uac00 \uc788\ub294 \uacbd\uc6b0, init{} \ube14\ub7ed\uc744 \uc0ac\uc6a9\ud55c\ub2e4. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"kotlin\" class=\"language-kotlin\">class InitOrderDemo(name: String) {\n    val firstProperty = \"First property: $name\".also(::println)\n    \n    init {\n        println(\"First initializer block that prints ${name}\")\n    }\n    \n    val secondProperty = \"Second property: ${name.length}\".also(::println)\n    \n    init {\n        println(\"Second initializer block that prints ${name.length}\")\n    }\n}<\/code><\/pre>\n\n\n\n<p>\ubcc0\uc218\uc5d0 \uac12\uc744 \ub300\uc785\ud558\ub294\uacbd\uc6b0, \uc0dd\uc131\uc790\ub85c \ub118\uc5b4\uc628 name\uc744 \uadf8\ub300\ub85c \uc0ac\uc6a9\ud588\uace0, init{} \ube14\ub7ed\uc758 \uc608\ub97c \ub4e4\uae30\uc704\ud574 \ubb38\uc7a5\uc744 \ucd9c\ub825\ud558\uace0 \uc788\ub2e4. \uc2e4\ud589\ud574\ubcf4\uba74, \ucf54\ub4dc \uc21c\uc11c\ub300\ub85c \uc2e4\ud589\ub41c\ub2e4.<\/p>\n\n\n\n<p>\ucd94\uac00\uc801\uc778 \uc0dd\uc131\uc790\ub97c \uc815\uc758\ud558\uace0 \uc2f6\uc744 \ub550 \ub2e4\uc74c\uacfc \uac19\uc774 constructor \ud0a4\uc6cc\ub4dc\ub97c \uc0ac\uc6a9\ud55c\ub2e4.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"kotlin\" class=\"language-kotlin\">class Person(val name: String) {\n    var children: MutableList&lt;Person> = mutableListOf&lt;Person>();\n    constructor(name: String, parent: Person) : this(name) {\n        parent.children.add(this)\n    }\n}<\/code><\/pre>\n\n\n\n<p>secondary constructor\ub97c \ub9cc\ub4dc\ub294\uacbd\uc6b0, this\ub97c \uc0ac\uc6a9\ud558\uc5ec primary constructor\ub97c \ubd88\ub7ec\uc918\uc57c\ud55c\ub2e4. init\ube14\ub7ed\uc774 \uc788\ub294\uacbd\uc6b0, primary \uc0dd\uc131\uc790\uac00 \ubd88\ub9b0 \uc774\ud6c4\uc5d0 \uc21c\uc11c\ub300\ub85c \uc2e4\ud589\ub41c\ub2e4.<\/p>\n\n\n\n<p>\uc0c1\uc18d\uc744 \ubc1b\ub294 \uacbd\uc6b0\uc5d0\ub3c4 secondary constructor\uc640 \uc720\uc0ac\ud558\ub2e4. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"kotlin\" class=\"language-kotlin\">open class Parent(p: Int)\n\nclass Derived(p: Int) : Parent(p)<\/code><\/pre>\n\n\n\n<p>primary constructor\ub97c \uc0ac\uc6a9\ud558\ub294 \uacbd\uc6b0, \uc704\uc640\uac19\uc774 \uc0ac\uc6a9\uc774\ub41c\ub2e4. secondary constructor\ub97c \uc0ac\uc6a9\ud558\ub294 \uacbd\uc6b0, \ub2e4\uc74c\uacfc \uac19\uc774 super \ud0a4\uc6cc\ub4dc\ub97c \uc0ac\uc6a9\ud55c\ub2e4.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"kotlin\" class=\"language-kotlin\">class MyView : View {\n    constructor(ctx: Context) : super(ctx)\n\n    constructor(ctx: Context, attrs: AttributeSet) : super(ctx, attrs)\n}<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator is-style-dots\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">C#<\/h3>\n\n\n\n<p>C++ \uc774\ub098 Java\uc5d0\uc11c \ubd10\uc654\ub4ef\uc774, \ud074\ub798\uc2a4 \uc774\ub984\uc73c\ub85c \uc0dd\uc131\uc790\ub97c \ub9cc\ub4e0\ub2e4. ( <a href=\"https:\/\/docs.microsoft.com\/ko-kr\/dotnet\/csharp\/programming-guide\/classes-and-structs\/constructors\">MS \uacf5\uc2dd\ubb38\uc11c \ucc38\uc870<\/a> )<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"csharp\" class=\"language-csharp\">public class Person\n{\n   private string last;\n   private string first;\n\n   public Person(string lastName, string firstName)\n   {\n      last = lastName;\n      first = firstName;\n   }\n\n   \/\/ Remaining implementation of Person class.\n}<\/code><\/pre>\n\n\n\n<p>\uc77c\ubc18\uc801\uc778 \uc0ac\uc6a9\uc2dc public \uc744 \ubc18\ub4dc\uc2dc \uc0ac\uc6a9\ud574\uc57c \ud558\ub294\uc810\uc744 \uc8fc\uc758\ud558\uc790. access modifier\uac00 \uc5c6\uc73c\uba74, \uae30\ubcf8\uac12\uc774 Internal\uc774 \uc0ac\uc6a9\ub418\uace0 \uc678\ubd80\uc5d0\uc11c \uc0dd\uc131\uc790\ub97c \ud638\ucd9c\ud558\uc9c0 \ubabb\ud55c\ub2e4. singleton\uc744 \ub9cc\ub4dc\ub294 \uacbd\uc6b0\uc5d0\ub294 private\uc744 \uc0ac\uc6a9\ud560 \uc218\ub3c4 \uc788\ub2e4.<br> \uba54\uc18c\ub4dc \uc624\ubc84\ub85c\ub529\uacfc \uac19\uc774, \uc0dd\uc131\uc790\ub3c4 \uc778\uc790\uc5d0 \ub530\ub77c \uc5ec\ub7ec\uac1c\ub97c \uc815\uc758\ud574 \uc0ac\uc6a9\uac00\ub2a5\ud558\ub2e4.<\/p>\n\n\n\n<p>\uc0c1\uc18d\uc744 \ud558\ub294 \uacbd\uc6b0, base \ud0a4\uc6cc\ub4dc\ub97c \uc0ac\uc6a9\ud558\uc5ec \ubd80\ubaa8 \ud074\ub798\uc2a4 \uc0dd\uc131\uc790\ub97c \ud638\ucd9c\ud55c\ub2e4. C#\uc5d0\uc11c\ub294 super \ud0a4\uc6cc\ub4dc\uac00 \uc5c6\uace0 \ub300\uc2e0 base\ub97c \uc4f4\ub2e4.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"csharp\" class=\"language-csharp\">public class Manager : Employee\n{\n    public Manager(int annualSalary)\n        : base(annualSalary)\n    {\n        \/\/Add further instructions here.\n    }\n}<\/code><\/pre>\n\n\n\n<p>\ucf54\ud2c0\ub9b0\uc5d0\uc11c secondary constructor\uac00 primary constructor\ub97c \ubd80\ub974\ub4ef C#\ub3c4 \uc790\uae30\uc790\uc2e0\uc758 \ub2e4\ub978 \uc0dd\uc131\uc790\ub97c \ubd80\ub97c \uc218 \uc788\ub2e4. \uc774 \ub54c\ub294 \ucf54\ud2c0\ub9b0\uacfc \ub3d9\uc77c\ud558\uac8c this\ub97c \uc0ac\uc6a9\ud55c\ub2e4.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"csharp\" class=\"language-csharp\">public Employee(int weeklySalary, int numberOfWeeks)\n    : this(weeklySalary * numberOfWeeks)\n{\n}<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator is-style-dots\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">Python<\/h3>\n\n\n\n<p>\ud30c\uc774\uc36c \ud074\ub798\uc2a4\ub294 \ub2e4\ub978 \uc5b8\uc5b4\ub4e4\uacfc\ub294 \ud615\ud0dc\uac00 \uc880 \ub9ce\uc774 \ub2e4\ub974\ub2e4. \uc0dd\uc131\uc790\ub294 __init__ \ub97c \uc0ac\uc6a9\ud558\ub294\ub370, dynamic type \uc5b8\uc5b4\uae30 \ub54c\ubb38\uc5d0 \uc624\ubc84\ub85c\ub529\uc774 \uc548\ub41c\ub2e4.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"python\" class=\"language-python\">class Component:\n    def __init__(self, name: str, pos: Position):\n        self._name: str = name\n        self._position: Position = pos\n...<\/code><\/pre>\n\n\n\n<p>python\uc5d0\uc11c \uba54\uc18c\ub4dc\ub4e4\uc758 \uccab\ubc88\uc9f8 \uc778\uc790\ub294 \ubb34\uc870\uac74 self\uc774\ub2e4. \uba54\uc18c\ub4dc\ub97c \ud638\ucd9c\ud560 \ub54c, \uc790\ub3d9\uc73c\ub85c \ucc44\uc6cc\uc9c4\ub2e4. member variable\uc740 self\ub97c \ubb34\uc870\uac74 \ubd99\uc5ec\uc11c \uc0ac\uc6a9\ud55c\ub2e4. python \ud2b9\uc131\uc0c1, \ub530\ub85c \uc815\uc758\ud558\ub294 \ubd80\ubd84\uc774 \uc5c6\uae30 \ub54c\ubb38\uc5d0 \ubcf4\ud1b5 __init__ \uc548\uc5d0\uc11c \uc804\ubd80 \uc815\uc758\ud558\uace0 \ucd08\uae30\ud654\ub97c \uc9c4\ud589\ud55c\ub2e4. \ub9cc\uc57d\uc5d0 __init__ \ub098 \ub2e4\ub978 \uba54\uc18c\ub4dc\uc5d0 \uc18d\ud558\uc9c0 \uc54a\ub3c4\ub85d \uc815\uc758\ud558\uba74 class variable\uc774 \ub41c\ub2e4.<\/p>\n\n\n\n<p>\uc0c1\uc18d\uc744 \uc0ac\uc6a9\ud558\ub294 \uacbd\uc6b0, \ub2e4\uc74c\uacfc \uac19\uc774 \uc0ac\uc6a9\ud55c\ub2e4.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"python\" class=\"language-python\">class Composite(Component):\n    def __init__(self, name: str, pos: Position):\n        super().__init__(name, pos)\n        self._leafs: List[Component] = []\n...<\/code><\/pre>\n\n\n\n<p>Python\uc5d0\uc11c \ud074\ub798\uc2a4 \uc0c1\uc18d\uc740 \uad04\ud638\uc548\uc5d0 \ubd80\ubaa8 \ud074\ub798\uc2a4\ub97c \ud45c\uae30\ud574\uc900\ub2e4. Composite class\uac00 Component class\ub97c \uc0c1\uc18d\ud558\uace0 \uc788\ub294\uac78 \ubcfc \uc218 \uc788\ub2e4.<br> \ud074\ub798\uc2a4 \ub0b4\uc5d0\uc11c super()\ub97c \uc0ac\uc6a9\ud558\uc5ec \ubd80\ubaa8 \ud074\ub798\uc2a4\ub97c \uc0ac\uc6a9\ud560 \uc218 \uc788\ub294\ub370, \uc0dd\uc131\uc790 \ucf54\ub4dc\ub0b4\uc5d0\uc11c suer().__init__()\ub97c \uc0ac\uc6a9\ud558\uc5ec \ubd80\ubaa8\ud074\ub798\uc2a4\uc758 \uc0dd\uc131\uc790\ub97c \ud638\ucd9c\ud574 \uc8fc\ub3c4\ub85d \ud55c\ub2e4. \ub2e4\ub978 \uc5b8\uc5b4\ub4e4\uc5d0\uc11c\ub3c4 \uc0dd\uc131\uc790\uac00 \ubd80\ubaa8 \ud074\ub798\uc2a4\ub97c \ub530\ub77c \uccb4\uc778\uc744 \uc774\ub8e8\ub4ef \ud638\ucd9c\ud574 \uc8fc\uac8c \ub418\ub294\ub370, \uc5ec\uae30\uc11c\ub3c4 \ub9c8\ucc2c\uac00\uc9c0\ub2e4.<\/p>\n\n\n\n<p>Python\uc5d0\uc11c \uac00\ub2a5\ud55c \ub2e4\uc911\uc0c1\uc18d\uc744 \uc0b4\ud3b4\ubcfc\ud150\ub370, \uadf8\uc804\uc5d0 \uc7a0\uae50 \uc5b8\uae09\ud560 \ub0b4\uc6a9\uc774\uc788\ub2e4. \uc5ec\uae30\uc11c \uc790\uc138\ud788 \ub2e4\ub8e8\uc9c0\ub294 \uc54a\uc9c0\ub9cc Python\uc740 \uae4a\uac8c \ud30c\uace0\ub4e4\uba74, \ud074\ub798\uc2a4\ub098 \uc0c1\uc18d\uc5d0 \ub300\ud574 \ub2e4\ub978 \ubaa8\uc2b5\ub4e4\uc774 \ub098\ud0c0\ub09c\ub2e4. class\ub3c4 \ud558\ub098\uc758 \uac1d\uccb4\uc5d0 \uc9c0\ub098\uc9c0 \uc54a\uc73c\uba70, \uadf8 \ucd5c\uc0c1\uc704\uc5d0\ub294 meta class\uac00 \uc874\uc7ac\ud55c\ub2e4. \uc2e4\uc81c \uc0c1\uc18d\uad00\uacc4\ub3c4 \uc774 meta class\uc5d0 \uc601\ud5a5\uc744 \ubc1b\ub294\ub2e4. Python\uc774 \ub2e4\uc911\uc0c1\uc18d\uc744 \uc9c0\uc6d0\ud558\uc9c0\ub9cc, meta class\ub294 \ub2e4\uc911\uc73c\ub85c \uc0c1\uc18d\ubc1b\uc9c0 \ubabb\ud55c\ub2e4. \uadf8\ub798\uc11c \ub2e4\ub978 meta class\ub97c \uac16\ub294 \ub450 \ud074\ub798\uc2a4\ub85c\ubd80\ud130\uc758 \uc0c1\uc18d\uc740 \uc8fc\uc758\uac00 \ud544\uc694\ud558\ub2e4. <\/p>\n\n\n\n<p> \ubcf4\ud1b5\uc758 \uacbd\uc6b0\uc5d0 metaclass\ub97c \uc9c1\uc811 \ub2e4\ub8e8\uc9c0\ub294 \uc54a\uc73c\ubbc0\ub85c \ub2e4\uc911\uc0c1\uc18d\uc774 \uac00\ub2a5\ud558\uace0 \uc774 \uacbd\uc6b0 MRO(method resolution order)\ub77c\ub294\uac78 \uccb4\ud06c\ud574\ubd10\uc57c \ud55c\ub2e4. ( <a href=\"https:\/\/www.python-course.eu\/python3_multiple_inheritance.php\">Python-course.eu \uc0ac\uc774\ud2b8 \ucc38\uc870<\/a> )<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"python\" class=\"language-python\">class B:\n    def x(self):\n        print('x: B')\n\n\nclass C:\n    def x(self):\n        print('x: C')\n\n\nclass D(B, C):\n    pass\n\nd = D()\nd.x()\nprint(D.mro())<\/code><\/pre>\n\n\n\n<p>\uc704\uc758 \ucf54\ub4dc\ub97c \uc2e4\ud589\ud574\ubcf4\uba74, class B\uc758 x()\uac00 \ud638\ucd9c\ub418\ub294\uac78 \uc54c \uc218 \uc788\ub2e4. \uadf8\ub9ac\uace0 mro\uc5d0\uc11c B class\uac00 \uc6b0\uc120\ub418\ub294 \uac83 \ub610\ud55c \ubcfc \uc218 \uc788\ub2e4.<\/p>\n\n\n\n<p>\ub2e4\uc911\uc0c1\uc18d\uc2dc \uac19\uc740 \uc774\ub984\uc758 \uba54\uc18c\ub4dc\uac00 \uc788\ub2e4\uba74, super\ub300\uc2e0\uc5d0 \ud638\ucd9c\ud558\uace0 \uc2f6\uc740 \ud074\ub798\uc2a4\ub97c \ubd99\uc5ec\uc11c \uc0ac\uc6a9\ud558\uba74 \ub41c\ub2e4.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"python\" class=\"language-python\">class D(B,C):\n    def m(self):\n        print(\"m of D called\")\n        B.m(self)\n        C.m(self)<\/code><\/pre>\n\n\n\n<p>\ub2e4\uc911\uc0c1\uc18d\uc5d0\uc11c\ub294 \ub2e4\uc774\uc544\ubaac\ub4dc \uc0c1\uc18d\uc744 \uaf2d \uc9da\uace0 \ub118\uc5b4\uac00\uc57c\ud55c\ub2e4.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"python\" class=\"language-python\">class A:\n    def __init__(self):\n        print(\"A.__init__\")\n\nclass B(A):\n    def __init__(self):\n        print(\"B.__init__\")\n        super().__init__()\n    \nclass C(A):\n    def __init__(self):\n        print(\"C.__init__\")\n        super().__init__()\n\n\nclass D(B,C):\n    def __init__(self):\n        print(\"D.__init__\")\n        super().__init__()\n\nd = D()<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">D.__init__\nB.__init__\nC.__init__\nA.__init__<\/code><\/pre>\n\n\n\n<p>\uc0c1\uc2dd\uc801\uc73c\ub85c \uc0dd\uac01\ud588\uc744 \ub54c, B\uc758 \uc0dd\uc131\uc790\uac00 \ud638\ucd9c\ub418\uace0 C\uc758 \uc0dd\uc131\uc790\uac00 \ud638\ucd9c\ub418\ubbc0\ub85c A\uc758 \uc0dd\uc131\uc790\uac00 \ub450\ubc88 \ud638\ucd9c\ub420 \uac83 \uac19\uc9c0\ub9cc, \ub9c8\uc9c0\ub9c9\uc5d0 \ud55c\ubc88\ub9cc \ud638\ucd9c\ub418\uace0 \uc788\ub2e4. \uc774\ub294 super()\uac00 \ubb34\uc870\uac74 \ubd80\ubaa8 \ud074\ub798\uc2a4\uc758 \ud568\uc218\ub97c \ud638\ucd9c\ud558\uc9c0 \uc54a\uace0, MRO \uc815\ubcf4\ub97c \uc774\uc6a9\ud558\uae30 \ub54c\ubb38\uc774\ub2e4. \uc2e4\uc81c\ub85c D\uc758 MRO\uc815\ubcf4\ub97c \ucd9c\ub825\ud574\ubcf4\uba74 \ub2e4\uc74c\uacfc \uac19\ub2e4.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">>>> D.mro()\n[&lt;class 'super_init.D'>, &lt;class 'super_init.B'>, &lt;class 'super_init.C'>, &lt;class 'super_init.A'>, &lt;class 'object'>]<\/code><\/pre>\n\n\n\n<p>\uc55e\uc5d0\uc11c \uc5b8\uae09\ud55c meta class\ub294 \ub2e4\uc911\uc0c1\uc18d \ubc1b\uc744 \uc218 \uc5c6\ub294 \uc774\uc720\uac00 \uc774 MRO\uac00 \uaf2c\uc774\uae30 \ub54c\ubb38\uc774\ub77c \uc0dd\uac01\ub41c\ub2e4.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\uc0c1\uc18d\uacfc \uad00\ub828\ud574\uc11c \uc0dd\uc131\uc790\ub294 \uc5b4\ub5bb\uac8c \uc5f0\uacb0\uc774 \ub418\ub294\uc9c0 \ud5f7\uac08\ub9b4\ub9cc\ud55c \ud3ec\uc778\ud2b8\ub4e4\uc774 \uc788\uc5b4 \ud55c \ubc88 \uc815\ub9ac\ud574 \ub193\ub294\ub2e4. Kotlin \ucf54\ud2c0\ub9b0\uc740 \uc0dd\uc131\uc790\uc5d0 \ud074\ub798\uc2a4\uc774\ub984\uc744 \uc4f0\uc9c0\uc54a\uace0 &#8216;constructor&#8217;\ub77c\ub294 \ud0a4\uc6cc\ub4dc\ub97c \uc4f4\ub2e4. \uc5ec\ub7ec \uc0dd\uc131\uc790\ub97c \uac00\uc9c8 \uc218 \uc788\uc73c\ub098, primary constructor\ub294 \ud074\ub798\uc2a4 \uccab \ub77c\uc778\uc744 \ud65c\uc6a9\ud55c\ub2e4. ( Kotlin \uacf5\uc2dd\ubb38\uc11c \ucc38\uc870 ) \ub450\ubc88\uc9f8 \ub77c\uc778\ucc98\ub7fc \ud0a4\uc6cc\ub4dc\ub97c \uc548\uc368\uc918\ub3c4 \ub41c\ub2e4. \ub610\ud55c, \uc138\ubc88\uc9f8\ucc98\ub7fc class property\uc815\uc758\ub97c \uc368\uc11c \ucd94\uac00\uc801\uc778 \ud560\ub2f9\ucf54\ub4dc\uc5c6\uc774 \uac04\ub2e8\ud558\uac8c <a href=\"http:\/\/batmask.net\/index.php\/2020\/05\/01\/492\/\" class=\"btn btn-link continue-link\">\ub354 \uc77d\uae30<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,24,6,34,33],"tags":[109,165,122,38,116,35,129,167,166,41,55],"class_list":["post-492","post","type-post","status-publish","format-standard","hentry","category-etc","category-note4reference","category-unity","category-kotlin","category-python","tag-c","tag-constructor","tag-inheritance","tag-kotlin","tag-oop","tag-python","tag-oop-kr","tag-inheritance-kr","tag-constructor-kr","tag-kotlin-kr","tag-python-kr"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"http:\/\/batmask.net\/index.php\/wp-json\/wp\/v2\/posts\/492","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/batmask.net\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/batmask.net\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/batmask.net\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/batmask.net\/index.php\/wp-json\/wp\/v2\/comments?post=492"}],"version-history":[{"count":13,"href":"http:\/\/batmask.net\/index.php\/wp-json\/wp\/v2\/posts\/492\/revisions"}],"predecessor-version":[{"id":506,"href":"http:\/\/batmask.net\/index.php\/wp-json\/wp\/v2\/posts\/492\/revisions\/506"}],"wp:attachment":[{"href":"http:\/\/batmask.net\/index.php\/wp-json\/wp\/v2\/media?parent=492"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/batmask.net\/index.php\/wp-json\/wp\/v2\/categories?post=492"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/batmask.net\/index.php\/wp-json\/wp\/v2\/tags?post=492"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}