{"id":9560,"date":"2020-09-22T12:15:33","date_gmt":"2020-09-22T08:45:33","guid":{"rendered":"https:\/\/maktabkhooneh.org\/mag\/?p=9560"},"modified":"2026-02-09T18:29:24","modified_gmt":"2026-02-09T14:59:24","slug":"what-is-constructor-c-plus-plus","status":"publish","type":"post","link":"https:\/\/maktabkhooneh.org\/mag\/what-is-constructor-c-plus-plus\/","title":{"rendered":"\u06a9\u0627\u0631\u0628\u0631\u062f Constructor c++ \u0686\u06cc\u0633\u062a"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\"><span style=\"font-size: 16px;\">Constructor c++ \u0686\u06cc\u0633\u062a<\/span><\/h2>\n\n\n\n<p><span style=\"font-size: 16px;\">\u0633\u0627\u0632\u0646\u062f\u0647 \u06cc\u0627&nbsp; Constructor c++&nbsp; \u0631\u0648\u0634 \u062e\u0627\u0635\u06cc \u0627\u0633\u062a \u06a9\u0647 \u0647\u0646\u06af\u0627\u0645 \u0627\u06cc\u062c\u0627\u062f \u06cc\u06a9 \u0634\u06cc \u0627\u0632 \u06a9\u0644\u0627\u0633 \u0628\u0647 \u0637\u0648\u0631 \u062e\u0648\u062f\u06a9\u0627\u0631 \u0641\u0631\u0627\u062e\u0648\u0627\u0646\u06cc \u0645\u06cc \u0634\u0648\u062f. \u0628\u0631\u0627\u06cc \u0627\u06cc\u062c\u0627\u062f \u06cc\u06a9 \u0633\u0627\u0632\u0646\u062f\u0647 \u06cc\u0627 constructor c++ \u0627\u0632 \u0647\u0645\u0627\u0646 \u0646\u0627\u0645 \u06a9\u0644\u0627\u0633 \u0648 \u0633\u067e\u0633 () \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0645\u06cc\u200c\u0634\u0648\u062f. \u0628\u0631\u0627\u06cc \u0627\u06cc\u0646\u06a9\u0647 \u0645\u0641\u0647\u0648\u0645 <strong>Constructor c++ \u0686\u06cc\u0633\u062a<\/strong> \u0631\u0627 \u0645\u0634\u062e\u0635 \u06a9\u0646\u06cc\u0645 \u0627\u06cc\u0646 \u0645\u0637\u0644\u0628 \u0631\u0627 \u062f\u0631 \u0627\u062e\u062a\u06cc\u0627\u0631 \u0634\u0645\u0627 \u0642\u0631\u0627\u0631 \u0645\u06cc\u200c\u062f\u0647\u06cc\u0645.&nbsp; \u0628\u0647 \u0645\u062b\u0627\u0644 \u0632\u06cc\u0631 \u062a\u0648\u062c\u0647 \u0646\u0645\u0627\u06cc\u06cc\u062f:<\/span><\/p>\n\n\n<div class=\"jet-listing-grid--50121\" style=\"\"><div class=\"jet-listing-dynamic-field-block zht-maktab-khooneh-course cb-fb2qc30r\"data-is-block=\"jet-engine\/dynamic-field\"><div class=\"jet-listing-dynamic-field__content\" >\n<div class=\"course-card\">\n    <div class=\"course-card-img\">\n        <img decoding=\"async\" \n            data-src=\"https:\/\/media1.maktabkhooneh.org\/CACHE\/images\/courses\/images\/C_card_1403-08-16-164658679\/4948bf79c99237119b4727880a0a5125.webp?expire=4893471932&#038;token=e23eb6ff27391a546be83880706eb9e3&#038;md5=4j62_yc5GlRr6DiAcG654w==\" \n            alt=\"\u0622\u0645\u0648\u0632\u0634 \u0628\u0631\u0646\u0627\u0645\u0647\u200c\u0646\u0648\u06cc\u0633\u06cc C++\" \n            title=\"\u0622\u0645\u0648\u0632\u0634 \u0628\u0631\u0646\u0627\u0645\u0647\u200c\u0646\u0648\u06cc\u0633\u06cc C++\" \n            width=\"100%\" \n            height=\"auto\"\n           \n         src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\">\n    <\/div>\n\n    <div class=\"course-details\">\n        <a href=\"https:\/\/maktabkhooneh.org\/course\/%D8%A8%D8%B1%D9%86%D8%A7%D9%85%D9%87-%D9%86%D9%88%DB%8C%D8%B3%DB%8C-%D8%B2%D8%A8%D8%A7%D9%86-c-plus-plus-mk361\/\" class=\"course-title\" target=\"_blank\" rel=\"noopener noreferrer\">\n            \u0622\u0645\u0648\u0632\u0634 \u0628\u0631\u0646\u0627\u0645\u0647\u200c\u0646\u0648\u06cc\u0633\u06cc C++        <\/a>\n\n        <div class=\"course-price\">\n            \n                <span class=\"real-price\">\n                                            \u06f1,\u06f8\u06f9\u06f9,\u06f0\u06f0\u06f0                                    <\/span>\n\n                <span>\n                    <span class=\"discounted-price\">\n                        \u06f8\u06f5\u06f4,\u06f5\u06f5\u06f0                    <\/span>\n                    <span class=\"price-currency\">\u062a\u0648\u0645\u0627\u0646<\/span>\n                <\/span>\n\n                                    <div class=\"discount-percentage\">\n                        \u06f5\u06f5%                    <\/div>\n                \n                    <\/div>\n        <button class=\"course-cta-button\" data-course-url=\"https:\/\/maktabkhooneh.org\/course\/%D8%A8%D8%B1%D9%86%D8%A7%D9%85%D9%87-%D9%86%D9%88%DB%8C%D8%B3%DB%8C-%D8%B2%D8%A8%D8%A7%D9%86-c-plus-plus-mk361\/\">\n            \u0645\u0634\u0627\u0647\u062f\u0647 \u0648 \u062e\u0631\u06cc\u062f        <\/button>\n    <\/div>\n<\/div>\n<\/div><\/div><\/div>\n\n\n<pre class=\"wp-block-preformatted\"><span style=\"font-size: 16px;\"> class MyClass {&nbsp; &nbsp; &nbsp;\/\/ The class\n\n&nbsp; public:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\/\/ Access specifier\n\n&nbsp; &nbsp; MyClass() {&nbsp; &nbsp; &nbsp;\/\/ Constructor\n\n&nbsp; &nbsp; &nbsp; cout &lt;&lt; \"Hello World!\";\n\n&nbsp; &nbsp; }\n\n};\n\n\n\n\nint main() {\n\n&nbsp; MyClass myObj;&nbsp; &nbsp; \/\/ Create an object of MyClass (this will call the constructor)\n\n&nbsp; return 0;\n\n}<\/span><\/pre>\n\n\n\n<p><span style=\"font-size: 16px;\">\u062e\u0631\u0648\u062c\u06cc \u0627\u06cc\u0646 \u0686\u0646\u062f \u062e\u0637 \u0628\u0631\u0646\u0627\u0645\u0647 Hello World! \u0627\u0633\u062a. \u0647\u0645\u0627\u0646 \u0639\u0628\u0627\u0631\u0627\u062a\u06cc \u06a9\u0647 \u062f\u0631 \u0648\u0633\u0637 \u0628\u0631\u0646\u0627\u0645\u0647 \u0646\u0648\u0634\u062a\u0647 \u0634\u062f\u0647 \u0627\u0633\u062a. \u0628\u0627 \u062a\u0648\u062c\u0647 \u0628\u0647 \u0627\u06cc\u0646 \u0645\u062b\u0627\u0644 \u0645\u062a\u0648\u062c\u0647 \u0634\u062f\u06cc\u0645 \u06a9\u0647 \u0633\u0627\u0632\u0646\u062f\u0647 \u067e\u06cc\u0634 \u0641\u0631\u0636 \u06cc\u0627 constructor c \u0647\u0645\u0627\u0646 \u0646\u0627\u0645 \u06a9\u0644\u0627\u0633 \u0631\u0627 \u062f\u0627\u0631\u062f \u0648 \u0647\u0645\u06cc\u0634\u0647 \u062d\u0627\u0644\u062a \u0639\u0645\u0648\u0645\u06cc \u062f\u0627\u0634\u062a\u0647 \u0648 \u0647\u06cc\u0686 \u0645\u0642\u062f\u0627\u0631 \u062e\u0631\u0648\u062c\u06cc \u0648 \u0628\u0627\u0632\u06af\u0634\u062a\u06cc \u0646\u062f\u0627\u0631\u062f. \u062f\u0631 \u0627\u062f\u0627\u0645\u0647 \u0628\u0647 \u067e\u0627\u0631\u0627\u0645\u062a\u0631\u0647\u0627\u06cc \u06cc\u06a9 constructor c++ \u0627\u0634\u0627\u0631\u0647 \u0645\u06cc\u200c\u0646\u0645\u0627\u06cc\u06cc\u0645.<\/span><\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter\"><img fetchpriority=\"high\" decoding=\"async\" width=\"1000\" height=\"562\" src=\"https:\/\/maktabkhooneh.org\/mag\/wp-content\/uploads\/2020\/09\/what-is-constructor-c-plus-plus-1.jpg\" alt=\"Constructor c++ \u0686\u06cc\u0633\u062a\" class=\"wp-image-9563\" title=\"\" srcset=\"https:\/\/maktabkhooneh.org\/mag\/wp-content\/uploads\/2020\/09\/what-is-constructor-c-plus-plus-1.jpg 1000w, https:\/\/maktabkhooneh.org\/mag\/wp-content\/smush-webp\/2020\/09\/what-is-constructor-c-plus-plus-1-300x169.jpg.webp 300w, https:\/\/maktabkhooneh.org\/mag\/wp-content\/smush-webp\/2020\/09\/what-is-constructor-c-plus-plus-1-768x432.jpg.webp 768w\" sizes=\"(max-width: 1000px) 100vw, 1000px\" \/><figcaption><\/figcaption><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\"><span style=\"font-size: 16px;\">\u067e\u0627\u0631\u0627\u0645\u062a\u0631\u0647\u0627\u06cc constructor c++ \u0686\u06cc\u0633\u062a<\/span><\/h3>\n\n\n\n<p><span style=\"font-size: 16px;\">\u0633\u0627\u0632\u0646\u062f\u0647 \u067e\u06cc\u0634 \u0641\u0631\u0636 \u06cc\u0627 constructor c \u06a9\u0647 \u062d\u062a\u06cc \u0628\u0631\u062e\u06cc \u0627\u0648\u0642\u0627\u062a \u0622\u0646 \u0631\u0627 default constructor \u062f\u0631 c++ \u0645\u06cc\u200c\u0646\u0627\u0645\u0646\u062f\u060c \u062f\u0642\u06cc\u0642\u0627 \u0645\u0627\u0646\u0646\u062f \u062a\u0648\u0627\u0628\u0639 \u0645\u06cc\u200c\u062a\u0648\u0627\u0646\u062f \u067e\u0627\u0631\u0627\u0645\u062a\u0631\u0647\u0627\u06cc\u06cc \u0631\u0627 \u0628\u06af\u06cc\u0631\u062f \u06a9\u0647 \u0627\u06cc\u0646 \u067e\u0627\u0631\u0627\u0645\u062a\u0631\u0647\u0627 \u0628\u0631\u0627\u06cc \u062a\u0646\u0638\u06cc\u0645 \u0645\u0642\u0627\u062f\u06cc\u0631 \u0627\u0648\u0644\u06cc\u0647 \u0648 \u0648\u06cc\u0698\u06af\u06cc\u200c\u0647\u0627\u06cc \u0645\u0631\u062a\u0628\u0637 \u0628\u0627 \u0622\u0646\u0647\u0627 \u0645\u0641\u06cc\u062f \u062e\u0648\u0627\u0647\u0646\u062f \u0628\u0648\u062f.<\/span><\/p>\n\n\n<div class=\"jet-listing-grid--50121\" style=\"\"><div class=\"jet-listing-dynamic-field-block zht-maktab-khooneh-course cb-fb2qc30r\"data-is-block=\"jet-engine\/dynamic-field\"><div class=\"jet-listing-dynamic-field__content\" >\n<div class=\"course-card\">\n    <div class=\"course-card-img\">\n        <img decoding=\"async\" \n            data-src=\"https:\/\/media1.maktabkhooneh.org\/CACHE\/images\/courses\/images\/bazargan4661436601033_1403-08-16-165213140\/0d1ab05c76877c420ea78ce3e72f8b8b.webp?expire=4893471932&#038;token=50be3d4a20c26001e8fde3c338043916&#038;md5=UL49SiDCYAHo_ePDOAQ5Fg==\" \n            alt=\"\u0627\u0635\u0648\u0644 \u0628\u0631\u0646\u0627\u0645\u0647 \u0646\u0648\u06cc\u0633\u06cc C \u0648 ++C\" \n            title=\"\u0627\u0635\u0648\u0644 \u0628\u0631\u0646\u0627\u0645\u0647 \u0646\u0648\u06cc\u0633\u06cc C \u0648 ++C\" \n            width=\"100%\" \n            height=\"auto\"\n           \n         src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\">\n    <\/div>\n\n    <div class=\"course-details\">\n        <a href=\"https:\/\/maktabkhooneh.org\/course\/%D8%A7%D8%B5%D9%88%D9%84-%D8%A8%D8%B1%D9%86%D8%A7%D9%85%D9%87-%D9%86%D9%88%DB%8C%D8%B3%DB%8C-c-%D9%88-c-mk68\/\" class=\"course-title\" target=\"_blank\" rel=\"noopener noreferrer\">\n            \u0627\u0635\u0648\u0644 \u0628\u0631\u0646\u0627\u0645\u0647 \u0646\u0648\u06cc\u0633\u06cc C \u0648 ++C        <\/a>\n\n        <div class=\"course-price\">\n            \n                <span class=\"free-price\">\u0631\u0627\u06cc\u06af\u0627\u0646<\/span>\n\n                    <\/div>\n        <button class=\"course-cta-button\" data-course-url=\"https:\/\/maktabkhooneh.org\/course\/%D8%A7%D8%B5%D9%88%D9%84-%D8%A8%D8%B1%D9%86%D8%A7%D9%85%D9%87-%D9%86%D9%88%DB%8C%D8%B3%DB%8C-c-%D9%88-c-mk68\/\">\n            \u0645\u0634\u0627\u0647\u062f\u0647        <\/button>\n    <\/div>\n<\/div>\n<\/div><\/div><\/div>\n\n\n<p><span style=\"font-size: 16px;\">\u062f\u0631 \u06a9\u0644\u0627\u0633 \u0632\u06cc\u0631 \u06a9\u0647 \u0634\u0627\u0645\u0644 \u0628\u0631\u0646\u062f\u060c \u0645\u062f\u0644 \u0648 \u0633\u0627\u0644 \u0627\u0633\u062a\u060c \u06cc\u06a9 \u0633\u0627\u0632\u0646\u062f\u0647 \u067e\u06cc\u0634 \u0641\u0631\u0636 \u0628\u0627 \u067e\u0627\u0631\u0627\u0645\u062a\u0631\u0647\u0627\u06cc \u0645\u062e\u062a\u0644\u0641 \u0648\u062c\u0648\u062f \u062f\u0627\u0631\u062f. \u062f\u0631 \u062f\u0627\u062e\u0644 \u0633\u0627\u0632\u0646\u062f\u0647 \u067e\u06cc\u0634 \u0641\u0631\u0636\u060c \u0635\u0641\u0627\u062a \u0631\u0627 \u0628\u0631\u0627\u0628\u0631 \u0628\u0627 \u067e\u0627\u0631\u0627\u0645\u062a\u0631\u0647\u0627\u06cc \u0633\u0627\u0632\u0646\u062f\u0647 \u0642\u0631\u0627\u0631 \u0645\u06cc\u200c\u062f\u0647\u06cc\u0645. \u0645\u062b\u0644\u0627 \u0628\u0631\u0646\u062f = x . \u0648\u0642\u062a\u06cc \u0633\u0627\u0632\u0646\u062f\u0647 \u067e\u06cc\u0634 \u0641\u0631\u0636 \u06cc\u0627 constructor c++ \u0641\u0631\u0627\u062e\u0648\u0627\u0646\u06cc \u0645\u06cc\u200c\u0634\u0648\u062f\u060c \u0645\u0642\u0627\u062f\u06cc\u0631 \u067e\u0627\u0631\u0627\u0645\u062a\u0631\u0647\u0627 \u0628\u0647 \u0633\u0627\u0632\u0646\u062f\u0647 \u0645\u0646\u062a\u0642\u0644 \u0645\u06cc\u200c\u0634\u0648\u062f. \u0628\u0647 \u0645\u062b\u0627\u0644 \u0632\u06cc\u0631 \u062a\u0648\u062c\u0647 \u0646\u0645\u0627\u06cc\u06cc\u062f:<\/span><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><span style=\"font-size: 16px;\">class Car {&nbsp; &nbsp; &nbsp; &nbsp; \/\/ The class\n\n&nbsp; public:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \/\/ Access specifier\n\n&nbsp; &nbsp; string brand;&nbsp; \/\/ Attribute\n\n&nbsp; &nbsp; string model;&nbsp; \/\/ Attribute\n\n&nbsp; &nbsp; int year;&nbsp; &nbsp; &nbsp; \/\/ Attribute\n\n&nbsp; &nbsp; Car(string x, string y, int z) { \/\/ Constructor with parameters\n\n&nbsp; &nbsp; &nbsp; brand = x;\n\n&nbsp; &nbsp; &nbsp; model = y;\n\n&nbsp; &nbsp; &nbsp; year = z;\n\n&nbsp; &nbsp; }\n\n};\n\n\n\n\nint main() {\n\n&nbsp; \/\/ Create Car objects and call the constructor with different values\n\n&nbsp; Car carObj1(\"BMW\", \"X5\", 1999);\n\n&nbsp; Car carObj2(\"Ford\", \"Mustang\", 1969);\n\n\n\n\n&nbsp; \/\/ Print values\n\n&nbsp; cout &lt;&lt; carObj1.brand &lt;&lt; \" \" &lt;&lt; carObj1.model &lt;&lt; \" \" &lt;&lt; carObj1.year &lt;&lt; \"\\n\";\n\n&nbsp; cout &lt;&lt; carObj2.brand &lt;&lt; \" \" &lt;&lt; carObj2.model &lt;&lt; \" \" &lt;&lt; carObj2.year &lt;&lt; \"\\n\";\n\n&nbsp; return 0;\n\n}<\/span><\/pre>\n\n\n\n<p><span style=\"font-size: 16px;\">\u062e\u0631\u0648\u062c\u06cc \u0627\u06cc\u0646 \u0628\u0631\u0646\u0627\u0645\u0647 \u0639\u0628\u0627\u0631\u062a \u0627\u0633\u062a \u0627\u0632:<\/span><\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><span style=\"font-size: 16px;\">BMW X5 1999<\/span><\/li>\n\n\n\n<li><span style=\"font-size: 16px;\">Ford Mustang 1969<\/span><\/li>\n<\/ol>\n\n\n\n<p><span style=\"font-size: 16px;\">\u062e\u0631\u0648\u062c\u06cc \u0634\u0627\u0645\u0644 \u0628\u0631\u0646\u062f \u062e\u0648\u062f\u0631\u0648\u060c \u0645\u062f\u0644 \u0648 \u0633\u0627\u0644 \u0633\u0627\u062e\u062a \u0645\u06cc \u0628\u0627\u0634\u062f.<\/span><\/p>\n\n\n\n<p><span style=\"font-size: 16px;\">\u062f\u0642\u06cc\u0642\u0627 \u0645\u0627\u0646\u0646\u062f \u062a\u0648\u0627\u0628\u0639\u060c \u0633\u0627\u0632\u0646\u062f\u0647 \u0647\u0627\u06cc \u067e\u06cc\u0634 \u0641\u0631\u0636 \u0631\u0627 \u0645\u06cc\u200c\u062a\u0648\u0627\u0646 \u062e\u0627\u0631\u062c \u0627\u0632 \u06a9\u0644\u0627\u0633 \u0646\u06cc\u0632 \u062a\u0639\u0631\u06cc\u0641 \u06a9\u0631\u062f. \u0627\u0628\u062a\u062f\u0627 \u0628\u0627\u06cc\u062f \u062f\u0631 \u062f\u0627\u062e\u0644 \u06a9\u0644\u0627\u0633 \u0633\u0627\u0632\u0646\u062f\u0647 \u0631\u0627 \u0645\u0639\u0631\u0641\u06cc \u0646\u0645\u0648\u062f \u0648 \u0633\u067e\u0633 \u062f\u0631 \u062e\u0627\u0631\u062c \u06a9\u0644\u0627\u0633 \u0628\u0627 \u0645\u0634\u062e\u0635 \u0646\u0645\u0648\u062f\u0646 \u0646\u0627\u0645 \u06a9\u0644\u0627\u0633 \u0641\u0631\u0627\u062e\u0648\u0627\u0646\u06cc \u0648 \u062e\u0631\u0648\u062c\u06cc \u0628\u0631\u0646\u0627\u0645\u0647 \u0631\u0627 \u062f\u0631\u06cc\u0627\u0641\u062a \u06a9\u0631\u062f. \u0628\u0647 \u0645\u062b\u0627\u0644 \u0632\u06cc\u0631 \u06a9\u0647 \u0645\u062a\u0646 \u062f\u06cc\u06af\u0631\u06cc \u0627\u0632 \u0645\u062b\u0627\u0644 \u0642\u0628\u0644 \u0627\u0633\u062a \u062f\u0642\u062a \u0646\u0645\u0627\u06cc\u06cc\u062f:<\/span><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><span style=\"font-size: 16px;\">class Car {&nbsp; &nbsp; &nbsp; &nbsp; \/\/ The class\n\n&nbsp; public:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \/\/ Access specifier\n\n&nbsp; &nbsp; string brand;&nbsp; \/\/ Attribute\n\n&nbsp; &nbsp; string model;&nbsp; \/\/ Attribute\n\n&nbsp; &nbsp; int year;&nbsp; &nbsp; &nbsp; \/\/ Attribute\n\n&nbsp; &nbsp; Car(string x, string y, int z); \/\/ Constructor declaration\n\n};\n\n\n\n\n\/\/ Constructor definition outside the class\n\nCar::Car(string x, string y, int z) {\n\n&nbsp; brand = x;\n\n&nbsp; model = y;\n\n&nbsp; year = z;\n\n}\n\n\n\n\nint main() {\n\n&nbsp; \/\/ Create Car objects and call the constructor with different values\n\n&nbsp; Car carObj1(\"BMW\", \"X5\", 1999);\n\n&nbsp; Car carObj2(\"Ford\", \"Mustang\", 1969);\n\n\n\n\n&nbsp; \/\/ Print values\n\n&nbsp; cout &lt;&lt; carObj1.brand &lt;&lt; \" \" &lt;&lt; carObj1.model &lt;&lt; \" \" &lt;&lt; carObj1.year &lt;&lt; \"\\n\";\n\n&nbsp; cout &lt;&lt; carObj2.brand &lt;&lt; \" \" &lt;&lt; carObj2.model &lt;&lt; \" \" &lt;&lt; carObj2.year &lt;&lt; \"\\n\";\n\n&nbsp; return 0;\n\n}<\/span><\/pre>\n\n\n\n<p><span style=\"font-size: 16px;\">\u062f\u0631 \u0627\u06cc\u0646 \u0628\u0631\u0646\u0627\u0645\u0647 \u062e\u0631\u0648\u062c\u06cc \u062a\u063a\u06cc\u06cc\u0631 \u0646\u0646\u0645\u0648\u062f\u0647 \u0627\u0633\u062a \u0628\u0644\u06a9\u0647 \u0633\u0627\u062e\u062a\u0627\u0631 \u06a9\u062f\u0646\u0648\u06cc\u0633\u06cc \u0647\u0645\u0627\u0646\u200c\u0637\u0648\u0631 \u06a9\u0647 \u06af\u0641\u062a\u0647 \u0634\u062f \u0645\u062a\u0641\u0627\u0648\u062a \u0637\u0631\u0627\u062d\u06cc \u0634\u062f\u0647 \u0627\u0633\u062a.<\/span><\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span style=\"font-size: 16px;\">\u0627\u0646\u0648\u0627\u0639 constructor c++<\/span><\/h3>\n\n\n\n<p><span style=\"font-size: 16px;\">\u0633\u0627\u0632\u0646\u062f\u0647\u200c\u0647\u0627 \u062f\u0631 c++ \u062f\u0631 \u0633\u0647 \u0642\u0627\u0644\u0628 \u067e\u06cc\u0634 \u0641\u0631\u0636\u060c \u067e\u0627\u0631\u0627\u0645\u062a\u0631\u06cc \u06cc\u0627 \u06a9\u067e\u06cc \u0648\u062c\u0648\u062f \u062f\u0627\u0631\u0646\u062f. \u0633\u0627\u0632\u0646\u062f\u0647 \u067e\u06cc\u0634 \u0641\u0631\u0636 \u06cc\u0627 constructor c \u06cc\u0627 \u0628\u0647 \u062a\u0639\u0628\u06cc\u0631 \u062f\u06cc\u06af\u0631 default constructor \u062f\u0631 c++ \u0628\u062e\u0634\u06cc \u0627\u0632 \u0628\u0631\u0646\u0627\u0645\u0647 \u0634\u0627\u0645\u0644 \u0646\u0627\u0645 \u06a9\u0644\u0627\u0633 \u0627\u0633\u062a \u06a9\u0647 \u0628\u0627 () \u062e\u0627\u062a\u0645\u0647 \u0645\u06cc\u200c\u067e\u0630\u06cc\u0631\u062f. \u062f\u0631 \u062d\u0627\u0644\u062a \u067e\u0627\u0631\u0627\u0645\u062a\u0631\u06cc \u0633\u0627\u0632\u0646\u062f\u0647\u200c\u0647\u0627\u060c \u0645\u0642\u0627\u062f\u06cc\u0631 \u067e\u0627\u0631\u0627\u0645\u062a\u0631 \u062f\u0631 \u062f\u0627\u062e\u0644 \u067e\u0631\u0627\u0646\u062a\u0632 \u0648\u0627\u0631\u062f \u0645\u06cc\u200c\u0634\u0648\u062f. \u062f\u0631 \u062d\u0627\u0644\u062a \u0633\u0627\u0632\u0646\u062f\u0647 copy constructor \u0646\u06cc\u0632 \u0627\u0632 \u06cc\u06a9 \u0642\u0627\u0644\u0628 \u06a9\u067e\u06cc \u0634\u062f\u0647 \u0642\u0628\u0644\u06cc \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0645\u06cc\u200c\u0634\u0648\u062f. \u0628\u0647 \u062a\u0635\u0648\u06cc\u0631 \u0632\u06cc\u0631 \u062a\u0648\u062c\u0647 \u0646\u0645\u0627\u06cc\u06cc\u062f.<\/span><\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter\"><img decoding=\"async\" width=\"1024\" height=\"323\" data-src=\"https:\/\/maktabkhooneh.org\/mag\/wp-content\/smush-webp\/2020\/09\/what-is-constructor-c-plus-plus-1-1024x323.png.webp\" alt=\"\u0627\u0646\u0648\u0627\u0639 constructor c++\" class=\"wp-image-9564 lazyload\" title=\"\" data-srcset=\"https:\/\/maktabkhooneh.org\/mag\/wp-content\/smush-webp\/2020\/09\/what-is-constructor-c-plus-plus-1-1024x323.png.webp 1024w, https:\/\/maktabkhooneh.org\/mag\/wp-content\/smush-webp\/2020\/09\/what-is-constructor-c-plus-plus-1-300x95.png.webp 300w, https:\/\/maktabkhooneh.org\/mag\/wp-content\/smush-webp\/2020\/09\/what-is-constructor-c-plus-plus-1-768x243.png.webp 768w, https:\/\/maktabkhooneh.org\/mag\/wp-content\/uploads\/2020\/09\/what-is-constructor-c-plus-plus-1.png 1200w\" data-sizes=\"(max-width: 1024px) 100vw, 1024px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 1024px; --smush-placeholder-aspect-ratio: 1024\/323;\" \/><figcaption><\/figcaption><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\"><span style=\"font-size: 16px;\">\u0627\u0646\u0648\u0627\u0639 \u067e\u06cc\u0634 \u0641\u0631\u0636 \u062f\u0631 c++<\/span><\/h3>\n\n\n\n<p><span style=\"font-size: 16px;\">\u0628\u0631\u0627\u06cc \u0647\u0631 \u06a9\u062f\u0627\u0645 \u0627\u0632 \u0628\u0631\u0646\u0627\u0645\u0647\u200c\u0647\u0627\u06cc \u0645\u0628\u062a\u0646\u06cc \u0628\u0631 \u0633\u0627\u0632\u0646\u062f\u0647\u200c\u0647\u0627 \u0645\u062b\u0627\u0644\u06cc \u0645\u06cc\u200c\u0632\u0646\u06cc\u0645.<\/span><\/p>\n\n\n<div class=\"jet-listing-grid--50192\" style=\"\"><style><\/style><section class=\"zht-related-post\" itemscope=\"\" itemtype=\"https:\/\/schema.org\/Article\" role=\"region\"\n  aria-label=\"Related article\">\n  <div class=\"zht-related-post-section-label\">\n    \u0645\u0637\u0627\u0644\u0628 \u0645\u0631\u062a\u0628\u0637\n  <\/div>\n  <img decoding=\"async\" width=\"300\" height=\"169\" data-src=\"https:\/\/maktabkhooneh.org\/mag\/wp-content\/smush-webp\/2020\/08\/6038586442907648-300x169.png.webp\" class=\"attachment-medium size-medium wp-post-image lazyload\" alt=\"\u06cc\u0627\u062f\u06af\u06cc\u0631\u06cc \u0632\u0628\u0627\u0646 \u0628\u0631\u0646\u0627\u0645\u0647\u200c\u0646\u0648\u06cc\u0633\u06cc ++C \u0628\u0647 \u0686\u0647 \u0635\u0648\u0631\u062a \u0627\u0633\u062a\" data-srcset=\"https:\/\/maktabkhooneh.org\/mag\/wp-content\/smush-webp\/2020\/08\/6038586442907648-300x169.png.webp 300w, https:\/\/maktabkhooneh.org\/mag\/wp-content\/smush-webp\/2020\/08\/6038586442907648-1024x576.png.webp 1024w, https:\/\/maktabkhooneh.org\/mag\/wp-content\/smush-webp\/2020\/08\/6038586442907648-768x432.png.webp 768w, https:\/\/maktabkhooneh.org\/mag\/wp-content\/smush-webp\/2020\/08\/6038586442907648-1536x864.png.webp 1536w, https:\/\/maktabkhooneh.org\/mag\/wp-content\/uploads\/2020\/08\/6038586442907648.png 1920w\" data-sizes=\"(max-width: 300px) 100vw, 300px\" title=\"\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 300px; --smush-placeholder-aspect-ratio: 300\/169;\">\n  <a href=\"https:\/\/maktabkhooneh.org\/mag\/examples-of-c-programming-and-sample-questions\/\" class=\"zht-related-post-title\"\n    itemprop=\"headline\" target=\"_blank\">\u0645\u062b\u0627\u0644 \u0647\u0627\u06cc \u0628\u0631\u0646\u0627\u0645\u0647 \u0646\u0648\u06cc\u0633\u06cc c++\u200e \u0648 \u0646\u0645\u0648\u0646\u0647 \u0633\u0648\u0622\u0644\u0627\u062a \u0622\u0646<\/a>\n<\/section><\/div>\n\n\n<p><span style=\"font-size: 16px;\">\u062d\u0627\u0644\u062a \u0627\u0648\u0644\u060c default : \u062f\u0631 \u0627\u06cc\u0646 \u062d\u0627\u0644\u062a \u0633\u0627\u0632\u0646\u062f\u0647 \u0641\u0627\u0642\u062f \u0622\u0631\u06af\u0648\u0645\u0627\u0646 \u0648 \u0648\u0631\u0648\u062f\u06cc \u0627\u0633\u062a.<\/span><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><span style=\"font-size: 16px;\">\/\/ Cpp program to illustrate the&nbsp;\n\n\/\/ concept of Constructors&nbsp;\n\n#include &lt;iostream&gt;&nbsp;\n\nusing namespace std;&nbsp;\n\n&nbsp;&nbsp;\n\nclass construct {&nbsp;\n\npublic:&nbsp;\n\n&nbsp; &nbsp; int a, b;&nbsp;\n\n&nbsp;&nbsp;\n\n&nbsp; &nbsp; \/\/ Default Constructor&nbsp;\n\n&nbsp; &nbsp; construct()&nbsp;\n\n&nbsp; &nbsp; {&nbsp;\n\n&nbsp; &nbsp; &nbsp; &nbsp; a = 10;&nbsp;\n\n&nbsp; &nbsp; &nbsp; &nbsp; b = 20;&nbsp;\n\n&nbsp; &nbsp; }&nbsp;\n\n};&nbsp;\n\n&nbsp;&nbsp;\n\nint main()&nbsp;\n\n{&nbsp;\n\n&nbsp; &nbsp; \/\/ Default constructor called automatically&nbsp;\n\n&nbsp; &nbsp; \/\/ when the object is created&nbsp;\n\n&nbsp; &nbsp; construct c;&nbsp;\n\n&nbsp; &nbsp; cout &lt;&lt; \"a: \" &lt;&lt; c.a &lt;&lt; endl&nbsp;\n\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;&lt; \"b: \" &lt;&lt; c.b;&nbsp;\n\n&nbsp; &nbsp; return 1;&nbsp;\n\n\t}<\/span><\/pre>\n\n\n\n<p><span style=\"font-size: 16px;\">\u062d\u0627\u0644\u062a \u062f\u0648\u0645\u060c \u067e\u0627\u0631\u0627\u0645\u062a\u0631\u06cc: \u062f\u0631 \u0627\u06cc\u0646 \u062d\u0627\u0644\u062a \u0622\u0631\u06af\u0648\u0645\u0627\u0646\u200c\u0647\u0627 \u0648 \u0648\u0631\u0648\u062f\u06cc\u200c\u0647\u0627 \u062f\u0627\u062e\u0644 \u067e\u0631\u0627\u0646\u062a\u0632 \u0648\u0627\u0631\u062f \u0634\u062f\u0647\u200c\u0627\u0646\u062f.<\/span><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><span style=\"font-size: 16px;\">\/\/ CPP program to illustrate&nbsp;\n\n\/\/ parameterized constructors&nbsp;\n\n#include &lt;iostream&gt;&nbsp;\n\nusing namespace std;&nbsp;\n\n&nbsp;&nbsp;\n\nclass Point {&nbsp;\n\nprivate:&nbsp;\n\n&nbsp; &nbsp; int x, y;&nbsp;\n\n&nbsp;&nbsp;\n\npublic:&nbsp;\n\n&nbsp; &nbsp; \/\/ Parameterized Constructor&nbsp;\n\n&nbsp; &nbsp; Point(int x1, int y1)&nbsp;\n\n&nbsp; &nbsp; {&nbsp;\n\n&nbsp; &nbsp; &nbsp; &nbsp; x = x1;&nbsp;\n\n&nbsp; &nbsp; &nbsp; &nbsp; y = y1;&nbsp;\n\n&nbsp; &nbsp; }&nbsp;\n\n&nbsp;&nbsp;\n\n&nbsp; &nbsp; int getX()&nbsp;\n\n&nbsp; &nbsp; {&nbsp;\n\n&nbsp; &nbsp; &nbsp; &nbsp; return x;&nbsp;\n\n&nbsp; &nbsp; }&nbsp;\n\n&nbsp; &nbsp; int getY()&nbsp;\n\n&nbsp; &nbsp; {&nbsp;\n\n&nbsp; &nbsp; &nbsp; &nbsp; return y;&nbsp;\n\n&nbsp; &nbsp; }&nbsp;\n\n};&nbsp;\n\n&nbsp;&nbsp;\n\nint main()&nbsp;\n\n{&nbsp;\n\n&nbsp; &nbsp; \/\/ Constructor called&nbsp;\n\n&nbsp; &nbsp; Point p1(10, 15);&nbsp;\n\n&nbsp;&nbsp;\n\n&nbsp; &nbsp; \/\/ Access values assigned by constructor&nbsp;\n\n&nbsp; &nbsp; cout &lt;&lt; \"p1.x = \" &lt;&lt; p1.getX() &lt;&lt; \", p1.y = \" &lt;&lt; p1.getY();&nbsp;\n\n&nbsp;&nbsp;\n\n&nbsp; &nbsp; return 0;&nbsp;\n\n}<\/span><\/pre>\n\n\n\n<p><span style=\"font-size: 16px;\">\u062d\u0627\u0644\u062a \u0633\u0648\u0645\u060c \u06a9\u067e\u06cc : \u062f\u0631 \u0627\u06cc\u0646 \u0628\u0631\u0646\u0627\u0645\u0647 \u06a9\u067e\u06cc \u0627\u0632 \u06cc\u06a9 \u06a9\u0644\u0627\u0633 \u0628\u0647 \u0639\u0646\u0648\u0627\u0646 \u0622\u0631\u06af\u0648\u0645\u0627\u0646 \u06cc\u06a9 \u0633\u0627\u0632\u0646\u062f\u0647 \u0648\u0627\u0631\u062f \u0634\u062f\u0647 \u0627\u0633\u062a.<\/span><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><span style=\"font-size: 16px;\">\/\/ Illustration&nbsp;\n\n#include \"iostream\"&nbsp;\n\nusing namespace std;&nbsp;\n\n&nbsp;&nbsp;\n\nclass point {&nbsp;\n\nprivate:&nbsp;\n\n&nbsp; double x, y;&nbsp;\n\n&nbsp;&nbsp;\n\npublic:&nbsp;\n\n&nbsp; \/\/ Non-default Constructor &amp; default Constructor&nbsp;\n\n&nbsp; point (double px, double py) {&nbsp;\n\n&nbsp; &nbsp; x = px, y = py;&nbsp;\n\n&nbsp; }&nbsp;\n\n};&nbsp;\n\n&nbsp;&nbsp;\n\nint main(void) {&nbsp;\n\n&nbsp; \/\/ Define an array of size 10 &amp; of type point&nbsp;\n\n&nbsp; \/\/ This line will cause error&nbsp;\n\n&nbsp; point a[10];&nbsp;\n\n&nbsp;&nbsp;\n\n&nbsp; \/\/ Remove above line and program will compile without error&nbsp;\n\n&nbsp; point b = point(5, 6);&nbsp;\n\n}<\/span><\/pre>\n\n\n\n<p><span style=\"font-size: 16px;\">\u0627\u06cc\u0646 \u0645\u0637\u0627\u0644\u0628 \u062a\u0645\u0627\u0645 \u0622\u0646 \u0686\u06cc\u0632\u06cc \u0628\u0648\u062f \u06a9\u0647 \u0628\u0627 \u0645\u062b\u0627\u0644\u0647\u0627\u06cc \u0645\u062a\u0639\u062f\u062f \u062f\u0631 \u062e\u0635\u0648\u0635 <strong>Constructor c++ \u0686\u06cc\u0633\u062a<\/strong> \u0644\u0627\u0632\u0645 \u0628\u0648\u062f \u062a\u0627 \u0628\u062f\u0627\u0646\u06cc\u0645. \u0628\u0627 <a href=\"https:\/\/maktabkhooneh.org\/mag\/\">\u0645\u06a9\u062a\u0648\u0628<\/a> \u0647\u0645\u0631\u0627\u0647 \u0628\u0627\u0634\u06cc\u062f \u062a\u0627 \u0627\u0637\u0644\u0627\u0639\u0627\u062a \u0628\u06cc\u0634\u062a\u0631\u06cc \u062f\u0631 \u062e\u0635\u0648\u0635 \u0646\u06a9\u0627\u062a \u0645\u0631\u062a\u0628\u0637 \u0628\u0627 \u0645\u0648\u0636\u0648\u0639\u0627\u062a <a href=\"https:\/\/maktabkhooneh.org\/mag\/category\/programming-and-it-training\/\">\u0628\u0631\u0646\u0627\u0645\u0647 \u0646\u0648\u06cc\u0633\u06cc<\/a> \u062f\u0631 \u0627\u062e\u062a\u06cc\u0627\u0631 \u0634\u0645\u0627 \u0639\u0644\u0627\u0642\u0647\u200c\u0645\u0646\u062f\u0627\u0646 \u0642\u0631\u0627\u0631 \u062f\u0647\u062f.<\/span><\/p>\n\n\n\n<p><span style=\"font-size: 16px;\">\u0628\u0627 \u062a\u0648\u062c\u0647 \u0628\u0647 \u0646\u06a9\u0627\u062a\u06cc \u06a9\u0647 \u0627\u0634\u0627\u0631\u0647 \u0634\u062f \u0645\u06cc\u200c\u062a\u0648\u0627\u0646\u06cc\u062f \u062e\u0631\u0648\u062c\u06cc \u067e\u0631\u0648\u0698\u0647\u200c\u0647\u0627\u06cc \u067e\u0627\u06cc\u0627\u0646\u06cc \u0631\u0627 \u0627\u0633\u062a\u062e\u0631\u0627\u062c \u0646\u0645\u0627\u06cc\u06cc\u062f \u0648 \u0628\u0627 \u062c\u0627\u06cc\u06af\u0632\u06cc\u0646\u06cc \u0645\u0637\u0627\u0644\u0628 \u0645\u0634\u0627\u0628\u0647 \u062f\u0631 \u06a9\u062f\u0647\u0627\u06cc \u0645\u0639\u0631\u0641\u06cc \u0634\u062f\u0647 \u0628\u0627\u0644\u0627\u060c \u062a\u0645\u0631\u06cc\u0646 \u0628\u0631\u0646\u0627\u0645\u0647 \u0646\u0648\u06cc\u0633\u06cc \u062f\u0627\u0634\u062a\u0647 \u0628\u0627\u0634\u06cc\u062f. \u0628\u0627 \u0645\u0627 \u0647\u0645\u0631\u0627\u0647 \u0628\u0627\u0634\u06cc\u062f \u062a\u0627 \u0628\u0627 \u062f\u0646\u06cc\u0627\u06cc \u062c\u0630\u0627\u0628 \u0628\u0631\u0646\u0627\u0645\u0647\u200c\u0646\u0648\u06cc\u0633\u06cc \u0628\u06cc\u0634\u062a\u0631 \u0622\u0634\u0646\u0627 \u0648 \u0647\u0645\u0631\u0627\u0647 \u0634\u0648\u06cc\u062f.<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Constructor c++ \u0686\u06cc\u0633\u062a \u0633\u0627\u0632\u0646\u062f\u0647 \u06cc\u0627&nbsp; Constructor c++&nbsp; \u0631\u0648\u0634 \u062e\u0627\u0635\u06cc \u0627\u0633\u062a \u06a9\u0647 \u0647\u0646\u06af\u0627\u0645 \u0627\u06cc\u062c\u0627\u062f \u06cc\u06a9 \u0634\u06cc \u0627\u0632 \u06a9\u0644\u0627\u0633 \u0628\u0647 \u0637\u0648\u0631 \u062e\u0648\u062f\u06a9\u0627\u0631 \u0641\u0631\u0627\u062e\u0648\u0627\u0646\u06cc \u0645\u06cc \u0634\u0648\u062f. \u0628\u0631\u0627\u06cc \u0627\u06cc\u062c\u0627\u062f \u06cc\u06a9 \u0633\u0627\u0632\u0646\u062f\u0647 \u06cc\u0627 constructor c++ \u0627\u0632 \u0647\u0645\u0627\u0646 \u0646\u0627\u0645 \u06a9\u0644\u0627\u0633 \u0648 \u0633\u067e\u0633 () \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0645\u06cc\u200c\u0634\u0648\u062f. \u0628\u0631\u0627\u06cc \u0627\u06cc\u0646\u06a9\u0647 \u0645\u0641\u0647\u0648\u0645 Constructor c++ \u0686\u06cc\u0633\u062a \u0631\u0627 \u0645\u0634\u062e\u0635 \u06a9\u0646\u06cc\u0645 \u0627\u06cc\u0646 \u0645\u0637\u0644\u0628 \u0631\u0627 \u062f\u0631 \u0627\u062e\u062a\u06cc\u0627\u0631 \u0634\u0645\u0627 \u0642\u0631\u0627\u0631 [&hellip;]<\/p>\n","protected":false},"author":78,"featured_media":9577,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[],"class_list":["post-9560","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-programming-and-it-training"],"_links":{"self":[{"href":"https:\/\/maktabkhooneh.org\/mag\/wp-json\/wp\/v2\/posts\/9560","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/maktabkhooneh.org\/mag\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/maktabkhooneh.org\/mag\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/maktabkhooneh.org\/mag\/wp-json\/wp\/v2\/users\/78"}],"replies":[{"embeddable":true,"href":"https:\/\/maktabkhooneh.org\/mag\/wp-json\/wp\/v2\/comments?post=9560"}],"version-history":[{"count":5,"href":"https:\/\/maktabkhooneh.org\/mag\/wp-json\/wp\/v2\/posts\/9560\/revisions"}],"predecessor-version":[{"id":59979,"href":"https:\/\/maktabkhooneh.org\/mag\/wp-json\/wp\/v2\/posts\/9560\/revisions\/59979"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/maktabkhooneh.org\/mag\/wp-json\/wp\/v2\/media\/9577"}],"wp:attachment":[{"href":"https:\/\/maktabkhooneh.org\/mag\/wp-json\/wp\/v2\/media?parent=9560"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/maktabkhooneh.org\/mag\/wp-json\/wp\/v2\/categories?post=9560"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/maktabkhooneh.org\/mag\/wp-json\/wp\/v2\/tags?post=9560"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}