{"id":10815,"date":"2024-03-15T00:42:44","date_gmt":"2024-03-15T00:42:44","guid":{"rendered":"https:\/\/adelnasim.com\/docs\/courses\/oop\/this\/"},"modified":"2024-04-07T01:19:47","modified_gmt":"2024-04-07T01:19:47","slug":"this","status":"publish","type":"docs","link":"https:\/\/adelnasim.com\/ar\/docs\/courses\/oop\/this\/","title":{"rendered":"\u0627\u0644\u0645\u0624\u0634\u0631 this"},"content":{"rendered":"<p>\u0641\u064a \u0644\u063a\u0627\u062a \u0627\u0644\u0628\u0631\u0645\u062c\u0629 \u0627\u0644\u0643\u0627\u0626\u0646\u064a\u0629 (OOP) \u0645\u062b\u0644 C++\u060c \u064a\u0643\u0648\u0646 \u0627\u0644\u0645\u0624\u0634\u0631 this \u0639\u0628\u0627\u0631\u0629 \u0639\u0646 \u0643\u0644\u0645\u0629 \u0623\u0633\u0627\u0633\u064a\u0629 \u062a\u064f\u0633\u062a\u062e\u062f\u0645 \u0644\u0644\u0625\u0634\u0627\u0631\u0629 \u0625\u0644\u0649 \u0627\u0644\u0643\u0627\u0626\u0646 \u0627\u0644\u062d\u0627\u0644\u064a \u062f\u0627\u062e\u0644 \u062f\u0627\u0644\u0629 \u0627\u0644\u0639\u0636\u0648. \u0625\u0646\u0647 \u0645\u0624\u0634\u0631 \u062e\u0627\u0635 \u064a\u062d\u0645\u0644 \u0639\u0646\u0648\u0627\u0646 \u0627\u0644\u0630\u0627\u0643\u0631\u0629 \u0644\u0645\u062b\u064a\u0644 \u0627\u0644\u0643\u0627\u0626\u0646 \u0627\u0644\u062d\u0627\u0644\u064a.<\/p>\n<p><strong>\u0645\u062b\u0627\u0644 1:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">#include &lt;iostream&gt;\r\nusing namespace std;\r\nclass stud {\r\n    public:\r\n        void address() {\r\n            cout &lt;&lt; this;\r\n        }\r\n};\r\nint main()\r\n{\r\n    stud a, b, c;\r\n    cout &lt;&lt; \"The adress of a\\t\";\r\n    a.address();\r\n    cout &lt;&lt; endl &lt;&lt; \"The adress of b\\t\";\r\n    b.address();\r\n    cout &lt;&lt; endl &lt;&lt; \"The adress of c\\t\";\r\n    c.address();\r\n    cout &lt;&lt; endl;\r\n    return 0;\r\n}\r\n<\/pre>\n<p>\u0641\u064a \u0647\u0630\u0627 \u0627\u0644\u0628\u0631\u0646\u0627\u0645\u062c\u060c \u0644\u062f\u064a\u0646\u0627 class \u064a\u0633\u0645\u0649 Stu\u060c \u0648\u0627\u0644\u0630\u064a \u064a\u062d\u062a\u0648\u064a \u0639\u0644\u0649 \u0639\u0646\u0648\u0627\u0646 \u062f\u0627\u0644\u0629 \u0627\u0644\u0639\u0636\u0648 address(). \u062a\u0642\u0648\u0645 \u062f\u0627\u0644\u0629 \u0627\u0644\u0639\u0636\u0648 \u0647\u0630\u0647 \u0628\u0628\u0633\u0627\u0637\u0629 \u0628\u0637\u0628\u0627\u0639\u0629 \u0639\u0646\u0648\u0627\u0646 \u0627\u0644\u0630\u0627\u0643\u0631\u0629 \u0644\u0644\u0643\u0627\u0626\u0646 \u0627\u0644\u062d\u0627\u0644\u064a \u0628\u0627\u0633\u062a\u062e\u062f\u0627\u0645 \u0627\u0644\u0645\u0624\u0634\u0631 this.<\/p>\n<p>\u0648\u0638\u064a\u0641\u0629 \u0627\u0644\u0645\u0624\u0634\u0631 this:<\/p>\n<ul>\n<li>\u0641\u064a \u062f\u0627\u0644\u0629 address() \u0644\u0640stud class\u060c \u064a\u0634\u064a\u0631 this \u0625\u0644\u0649 \u0627\u0644\u0643\u0627\u0626\u0646 \u0627\u0644\u062d\u0627\u0644\u064a \u0627\u0644\u0630\u064a \u064a\u062a\u0645 \u0627\u0633\u062a\u062f\u0639\u0627\u0621 \u062f\u0627\u0644\u0629 \u0627\u0644\u0639\u0636\u0648 \u0645\u0646 \u0623\u062c\u0644\u0647.<\/li>\n<li>\u062f\u0627\u062e\u0644 \u0627\u0644\u062f\u0627\u0644\u0629 (address()) \u064a\u0642\u0648\u0645\ncout &lt;&lt; this; \u0628\u0637\u0628\u0627\u0639\u0629 \u0639\u0646\u0648\u0627\u0646 \u0627\u0644\u0630\u0627\u0643\u0631\u0629 \u0644\u0644\u0643\u0627\u0626\u0646 \u0627\u0644\u062d\u0627\u0644\u064a.<\/li>\n<li>\u0641\u064a \u0627\u0644\u062f\u0627\u0644\u0629 main()\u060c \u0646\u0642\u0648\u0645 \u0628\u0625\u0646\u0634\u0627\u0621 \u062b\u0644\u0627\u062b\u0629 \u0643\u0627\u0626\u0646\u0627\u062a a \u0648b \u0648c \u0645\u0646 class stud.<\/li>\n<li>\u0646\u0642\u0648\u0645 \u0628\u0639\u062f \u0630\u0644\u0643 \u0628\u0627\u0633\u062a\u062f\u0639\u0627\u0621 \u0627\u0644\u062f\u0627\u0644\u0629 address() \u0639\u0644\u0649 \u0643\u0644 \u0643\u0627\u0626\u0646\u060c \u0648\u0627\u0644\u062a\u064a \u062a\u0637\u0628\u0639 \u0639\u0646\u0648\u0627\u0646 \u0627\u0644\u0630\u0627\u0643\u0631\u0629 \u0644\u0643\u0644 \u0643\u0627\u0626\u0646.<\/li>\n<li>\u064a\u0636\u0645\u0646 \u0627\u0644\u0645\u0624\u0634\u0631 this \u0637\u0628\u0627\u0639\u0629 \u0639\u0646\u0648\u0627\u0646 \u0627\u0644\u0630\u0627\u0643\u0631\u0629 \u0627\u0644\u0635\u062d\u064a\u062d \u0644\u0644\u0643\u0627\u0626\u0646 \u0627\u0644\u062d\u0627\u0644\u064a \u0639\u0646\u062f \u0627\u0633\u062a\u062f\u0639\u0627\u0621 \u062f\u0627\u0644\u0629 address() \u0644\u0643\u0644 \u0643\u0627\u0626\u0646.<\/li>\n<\/ul>\n<p><strong>\u0645\u062b\u0627\u0644 2:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">#include &lt;iostream&gt;\r\nusing namespace std;\r\nclass Student {\r\n        int id;\r\n    public:\r\n        void set_id(int id) {\r\n            this-&gt;id = id;\r\n        }\r\n        void print_id() {\r\n            cout &lt;&lt; \"ID is \" &lt;&lt; id &lt;&lt; endl;\r\n        }\r\n};\r\nint main()\r\n{\r\n    Student St;\r\n    St.set_id(10);\r\n    St.print_id();\r\n    return 0;\r\n}\r\n<\/pre>\n<p>\u0641\u064a \u0647\u0630\u0627 \u0627\u0644\u0628\u0631\u0646\u0627\u0645\u062c\u060c \u0644\u062f\u064a\u0646\u0627 class \u0627\u0633\u0645\u0647 Student \u0645\u0639 \u0645\u0639\u0631\u0641 \u0645\u062a\u063a\u064a\u0631 \u0639\u0636\u0648 \u062e\u0627\u0635 \u064a\u0645\u062b\u0644 id \u0627\u0644\u0637\u0627\u0644\u0628. \u064a\u0648\u0641\u0631 \u0627\u0644\u0640class \u062f\u0627\u0644\u062a\u064a\u0646 \u0644\u0644\u0639\u0636\u0648: set_id() \u0648print_id().<\/p>\n<p>\u0648\u0638\u064a\u0641\u0629 \u0627\u0644\u0645\u0624\u0634\u0631 this:<\/p>\n<ul>\n<li>\u0641\u064a \u062f\u0627\u0644\u0629 \u0627\u0644\u0639\u0636\u0648 set_id()\u060c \u0645\u0639\u0631\u0641 \u0627\u0644\u0645\u0639\u0644\u0645\u0629 \u0627\u0644\u0630\u064a \u062a\u0645 \u062a\u0645\u0631\u064a\u0631\u0647 \u0625\u0644\u0649 \u0627\u0644\u062f\u0627\u0644\u0629\u0644\u0647 \u0646\u0641\u0633 \u0627\u0633\u0645 \u0645\u0639\u0631\u0641 \u0645\u062a\u063a\u064a\u0631 \u0627\u0644\u0639\u0636\u0648 \u0644\u0644\u0641\u0626\u0629. \u0644\u0644\u062a\u0645\u064a\u064a\u0632 \u0628\u064a\u0646\u0647\u0645\u0627\u060c \u064a\u062a\u0645 \u0627\u0633\u062a\u062e\u062f\u0627\u0645 \u0627\u0644\u0645\u0624\u0634\u0631 this.<\/li>\n<li>\u062f\u0627\u062e\u0644 \u0627\u0644\u062f\u0627\u0644\u0629 set_id()\u060c this-&gt;id = id; \u064a\u0639\u064a\u0646 \u0642\u064a\u0645\u0629 \u0645\u0639\u0631\u0641 \u0627\u0644\u0645\u0639\u0644\u0645\u0629 \u0644\u0645\u0639\u0631\u0641 \u0645\u062a\u063a\u064a\u0631 \u0627\u0644\u0639\u0636\u0648 \u0644\u0644\u0643\u0627\u0626\u0646 \u0627\u0644\u062d\u0627\u0644\u064a.<\/li>\n<li>\u064a\u0634\u064a\u0631 \u0627\u0644\u0645\u0624\u0634\u0631 this  \u0625\u0644\u0649 \u0627\u0644\u0643\u0627\u0626\u0646 \u0627\u0644\u062d\u0627\u0644\u064a \u0627\u0644\u0630\u064a \u064a\u062a\u0645 \u0627\u0633\u062a\u062f\u0639\u0627\u0621 \u062f\u0627\u0644\u0629 \u0627\u0644\u0639\u0636\u0648 \u0645\u0646 \u0623\u062c\u0644\u0647. \u064a\u062a\u0645 \u0627\u0633\u062a\u062e\u062f\u0627\u0645\u0647 \u0644\u0644\u0648\u0635\u0648\u0644 \u0625\u0644\u0649 \u0623\u0639\u0636\u0627\u0621 \u0627\u0644\u0643\u0627\u0626\u0646.<\/li>\n<li>\u0641\u064a \u0627\u0644\u062f\u0627\u0644\u0629 main()\u060c \u064a\u062a\u0645 \u0625\u0646\u0634\u0627\u0621 \u0643\u0627\u0626\u0646 St \u0645\u0646 \u0641\u0626\u0629 Student. \u064a\u062a\u0645 \u0627\u0633\u062a\u062f\u0639\u0627\u0621 \u0627\u0644\u062f\u0627\u0644\u0629 set_id() \u0644\u062a\u0639\u064a\u064a\u0646 \u0645\u0639\u0631\u0641 \u0627\u0644\u0643\u0627\u0626\u0646 St \u0625\u0644\u0649 10.<\/li>\n<li>\u062b\u0645 \u064a\u062a\u0645 \u0627\u0633\u062a\u062f\u0639\u0627\u0621 \u0627\u0644\u062f\u0627\u0644\u0629 print_id() \u0644\u0637\u0628\u0627\u0639\u0629 \u0645\u0639\u0631\u0641 \u0627\u0644\u0643\u0627\u0626\u0646 St.<\/li>\n<\/ul>\n<p>\u0633\u062a\u0643\u0648\u0646 \u0645\u062e\u0631\u062c\u0627\u062a \u0627\u0644\u0628\u0631\u0646\u0627\u0645\u062c \u0643\u0627\u0644\u062a\u0627\u0644\u064a:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">ID is 10<\/pre>\n<p>&nbsp;<\/p>","protected":false},"excerpt":{"rendered":"<p>In object-oriented programming (OOP) languages like C++, the this pointer is a keyword that is used to refer to the current object within a member function. It is a special pointer that holds the memory address of the current object instance. Example 1: #include &lt;iostream&gt; using namespace std; class stud { public: void address() { [&hellip;]<\/p>","protected":false},"author":3,"featured_media":0,"parent":4291,"menu_order":52,"comment_status":"closed","ping_status":"closed","template":"","doc_tag":[],"class_list":["post-10815","docs","type-docs","status-publish","hentry","no-post-thumbnail"],"acf":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/adelnasim.com\/ar\/wp-json\/wp\/v2\/docs\/10815","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/adelnasim.com\/ar\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/adelnasim.com\/ar\/wp-json\/wp\/v2\/types\/docs"}],"author":[{"embeddable":true,"href":"https:\/\/adelnasim.com\/ar\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/adelnasim.com\/ar\/wp-json\/wp\/v2\/comments?post=10815"}],"version-history":[{"count":5,"href":"https:\/\/adelnasim.com\/ar\/wp-json\/wp\/v2\/docs\/10815\/revisions"}],"predecessor-version":[{"id":10824,"href":"https:\/\/adelnasim.com\/ar\/wp-json\/wp\/v2\/docs\/10815\/revisions\/10824"}],"up":[{"embeddable":true,"href":"https:\/\/adelnasim.com\/ar\/wp-json\/wp\/v2\/docs\/4291"}],"wp:attachment":[{"href":"https:\/\/adelnasim.com\/ar\/wp-json\/wp\/v2\/media?parent=10815"}],"wp:term":[{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/adelnasim.com\/ar\/wp-json\/wp\/v2\/doc_tag?post=10815"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}