{"id":10664,"date":"2024-02-27T14:26:17","date_gmt":"2024-02-27T14:26:17","guid":{"rendered":"https:\/\/adelnasim.com\/docs\/courses\/oop\/static-class-member-static-member-function\/"},"modified":"2024-04-07T01:19:45","modified_gmt":"2024-04-07T01:19:45","slug":"static-class-member-static-member-function","status":"publish","type":"docs","link":"https:\/\/adelnasim.com\/ar\/docs\/courses\/oop\/static-class-member-static-member-function\/","title":{"rendered":"\u0634\u0631\u062d \u0644\u0640 Static Class Member \u0648 Static Member Function"},"content":{"rendered":"<h1>\u0627\u0644\u0645\u0642\u062f\u0645\u0629<\/h1>\n<p>\u0641\u064a \u0644\u063a\u0629 C++\u060c \u064a\u0642\u062f\u0645 \"static class members\" \u0648\"static member functions\" \u0639\u0646\u0627\u0635\u0631 \u0639\u0644\u0649 \u0645\u0633\u062a\u0648\u0649 \u0627\u0644\u0641\u0626\u0629 \u063a\u064a\u0631 \u0645\u0631\u062a\u0628\u0637\u0629 \u0628\u0627\u0644\u0643\u0627\u0626\u0646\u0627\u062a \u0627\u0644\u0641\u0631\u062f\u064a\u0629 \u0644\u0644\u0641\u0626\u0629.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">#include &lt;iostream&gt;\r\n#include &lt;string&gt;\r\nusing namespace std;\r\nvoid f()\r\n{\r\n    static int x = 0;\r\n    x++;\r\n    cout &lt;&lt; x &lt;&lt; endl;\r\n}\r\nint main()\r\n{\r\n    f();\r\n    f();\r\n    return 0;\r\n}\r\n<\/pre>\n<p>\u064a\u0639\u0631\u0651\u0641 \u0628\u0631\u0646\u0627\u0645\u062c C++ \u0647\u0630\u0627 \u0627\u0644\u062f\u0627\u0644\u0629 f() \u0627\u0644\u062a\u064a \u062a\u0632\u064a\u062f \u0645\u062a\u063a\u064a\u0631\u064b\u0627 \u0635\u062d\u064a\u062d\u064b\u0627 \u062b\u0627\u0628\u062a\u064b\u0627 x \u0641\u064a \u0643\u0644 \u0645\u0631\u0629 \u064a\u062a\u0645 \u0627\u0633\u062a\u062f\u0639\u0627\u0624\u0647\u0627\u060c \u062b\u0645 \u062a\u0637\u0628\u0639 \u0642\u064a\u0645\u0629 x \u0625\u0644\u0649 \u0627\u0644\u0645\u062e\u0631\u062c\u0627\u062a \u0627\u0644\u0642\u064a\u0627\u0633\u064a\u0629. \u0627\u0644\u062f\u0627\u0644\u0629 main() \u062a\u0633\u062a\u062f\u0639\u064a f() \u0645\u0631\u062a\u064a\u0646.<\/p>\n<p>\u0625\u0644\u064a\u0643 \u0645\u0627 \u064a\u0641\u0639\u0644\u0647 \u0627\u0644\u0628\u0631\u0646\u0627\u0645\u062c:<\/p>\n<ul>\n<li>\u062a\u0645 \u062a\u0639\u0631\u064a\u0641 \u0627\u0644\u062f\u0627\u0644\u0629 f(). \u0623\u0646\u0647 \u064a\u062d\u062a\u0648\u064a \u0639\u0644\u0649 \u0645\u062a\u063a\u064a\u0631 static x \u062a\u0645\u062a \u062a\u0647\u064a\u0626\u062a\u0647 \u0625\u0644\u0649 0.<\/li>\n<li>\u0641\u064a \u0643\u0644 \u0645\u0631\u0629 \u064a\u062a\u0645 \u0627\u0633\u062a\u062f\u0639\u0627\u0621 \u0627\u0644\u062f\u0627\u0644\u0629 f()\u200e\u060c \u0641\u0625\u0646\u0647\u0627 \u062a\u0632\u064a\u062f x \u0628\u0645\u0642\u062f\u0627\u0631 1 \u0648\u062a\u0637\u0628\u0639 \u0627\u0644\u0642\u064a\u0645\u0629 \u0627\u0644\u062c\u062f\u064a\u062f\u0629 \u0644\u0640 x.<\/li>\n<li>\u0641\u064a \u0627\u0644\u062f\u0627\u0644\u0629 main()\u060c \u064a\u062a\u0645 \u0627\u0633\u062a\u062f\u0639\u0627\u0621 f() \u0645\u0631\u062a\u064a\u0646.<\/li>\n<li>\u0639\u0646\u062f\u0645\u0627 \u064a\u062a\u0645 \u0627\u0633\u062a\u062f\u0639\u0627\u0621 f() \u0644\u0644\u0645\u0631\u0629 \u0627\u0644\u0623\u0648\u0644\u0649\u060c \u062a\u062a\u0645 \u0632\u064a\u0627\u062f\u0629 x \u0645\u0646 0 \u0625\u0644\u0649 1\u060c \u0648\u064a\u062a\u0645 \u0637\u0628\u0627\u0639\u0629 1.<\/li>\n<li>\u0639\u0646\u062f\u0645\u0627 \u064a\u062a\u0645 \u0627\u0633\u062a\u062f\u0639\u0627\u0621 f() \u0644\u0644\u0645\u0631\u0629 \u0627\u0644\u062b\u0627\u0646\u064a\u0629\u060c \u062a\u062a\u0645 \u0632\u064a\u0627\u062f\u0629 x \u0645\u0646 1 \u0625\u0644\u0649 2\u060c \u0648\u064a\u062a\u0645 \u0637\u0628\u0627\u0639\u0629 2.<\/li>\n<\/ul>\n<p>\u0648\u0644\u0630\u0644\u0643\u060c \u0639\u0646\u062f \u062a\u0634\u063a\u064a\u0644 \u0627\u0644\u0628\u0631\u0646\u0627\u0645\u062c\u060c \u064a\u062c\u0628 \u0623\u0646 \u062a\u0643\u0648\u0646 \u0627\u0644\u0645\u062e\u0631\u062c\u0627\u062a \u0643\u0627\u0644\u062a\u0627\u0644\u064a:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">1\r\n2\r\n<\/pre>\n<p>\u0625\u0644\u064a\u0643 \u0645\u0627 \u064a\u0641\u0639\u0644\u0647 static \u0641\u064a \u0647\u0630\u0627 \u0627\u0644\u0633\u064a\u0627\u0642:<\/p>\n<ol>\n<li>\u0627\u0644\u062d\u0641\u0627\u0638 \u0639\u0644\u0649 \u0627\u0644\u0642\u064a\u0645\u0629 \u0628\u064a\u0646 \u0627\u0633\u062a\u062f\u0639\u0627\u0621\u0627\u062a \u0627\u0644\u062f\u0648\u0627\u0644: \u0639\u0646\u062f\u0645\u0627 \u064a\u062a\u0645 \u062a\u0639\u0631\u064a\u0641 \u0645\u062a\u063a\u064a\u0631 \u0639\u0644\u0649 \u0623\u0646\u0647 static \u062f\u0627\u062e\u0644 \u062f\u0627\u0644\u0629\u060c \u0641\u0625\u0646 \u0642\u064a\u0645\u062a\u0647 \u062a\u0633\u062a\u0645\u0631 \u0628\u064a\u0646 \u0627\u0633\u062a\u062f\u0639\u0627\u0621\u0627\u062a \u0627\u0644\u062f\u0648\u0627\u0644. \u0648\u0647\u0630\u0627 \u064a\u0639\u0646\u064a \u0623\u0646 \u0627\u0644\u0645\u062a\u063a\u064a\u0631 \u064a\u062d\u062a\u0641\u0638 \u0628\u0642\u064a\u0645\u062a\u0647 \u062d\u062a\u0649 \u0628\u0639\u062f \u062e\u0631\u0648\u062c \u0627\u0644\u062f\u0627\u0644\u0629 f(). \u0641\u064a \u0627\u0644\u0645\u062b\u0627\u0644\u060c \u064a\u062d\u062a\u0641\u0638 \u0627\u0644\u0645\u062a\u063a\u064a\u0631 x \u0628\u0642\u064a\u0645\u062a\u0647 \u0628\u064a\u0646 \u0627\u0633\u062a\u062f\u0639\u0627\u0621\u0627\u062a f().<\/li>\n<li>\u0627\u0644\u062a\u0647\u064a\u0626\u0629: \u062a\u062a\u0645 \u062a\u0647\u064a\u0626\u0629 \u0627\u0644\u0645\u062a\u063a\u064a\u0631\u0627\u062a \u0627\u0644\u062b\u0627\u0628\u062a\u0629 Static \u0645\u0631\u0629 \u0648\u0627\u062d\u062f\u0629 \u0641\u0642\u0637\u060c \u0641\u064a \u0628\u062f\u0627\u064a\u0629 \u062a\u0646\u0641\u064a\u0630 \u0627\u0644\u0628\u0631\u0646\u0627\u0645\u062c. \u0641\u064a \u0647\u0630\u0647 \u0627\u0644\u062d\u0627\u0644\u0629\u060c \u062a\u062a\u0645 \u062a\u0647\u064a\u0626\u0629 \u0627\u0644\u0645\u062a\u063a\u064a\u0631 Static x \u0625\u0644\u0649 0 \u0641\u064a \u0627\u0644\u0645\u0631\u0629 \u0627\u0644\u0623\u0648\u0644\u0649 \u0627\u0644\u062a\u064a \u064a\u062a\u0645 \u0641\u064a\u0647\u0627 \u0627\u0633\u062a\u062f\u0639\u0627\u0621 \u0627\u0644\u062f\u0627\u0644\u0629 f(). \u0644\u0627 \u062a\u0624\u062f\u064a \u0627\u0644\u0627\u0633\u062a\u062f\u0639\u0627\u0621\u0627\u062a \u0627\u0644\u0644\u0627\u062d\u0642\u0629 \u0625\u0644\u0649 f() \u0625\u0644\u0649 \u0625\u0639\u0627\u062f\u0629 \u062a\u0647\u064a\u0626\u0629 x.<\/li>\n<li>\u0645\u062f\u0629 \u0627\u0644\u062a\u062e\u0632\u064a\u0646: \u0627\u0644\u0645\u062a\u063a\u064a\u0631\u0627\u062a \u0627\u0644\u062b\u0627\u0628\u062a\u0629 Static \u0644\u0647\u0627 \"\u0645\u062f\u0629 \u062a\u062e\u0632\u064a\u0646 \u062b\u0627\u0628\u062a\u0629\"\u060c \u0645\u0645\u0627 \u064a\u0639\u0646\u064a \u0623\u0646\u0647\u0627 \u0645\u062e\u0635\u0635\u0629 \u0644\u0644\u0630\u0627\u0643\u0631\u0629 \u0637\u0648\u0627\u0644 \u0645\u062f\u0629 \u062a\u0646\u0641\u064a\u0630 \u0627\u0644\u0628\u0631\u0646\u0627\u0645\u062c. \u064a\u062a\u0645 \u062a\u062e\u0635\u064a\u0635 \u0647\u0630\u0647 \u0627\u0644\u0630\u0627\u0643\u0631\u0629 \u0641\u064a \u062c\u0632\u0621 \u0627\u0644\u0628\u064a\u0627\u0646\u0627\u062a \u0645\u0646 \u0627\u0644\u0628\u0631\u0646\u0627\u0645\u062c.<\/li>\n<li>\u0627\u0644\u0646\u0637\u0627\u0642: \u064a\u0642\u062a\u0635\u0631 \u0646\u0637\u0627\u0642 \u0627\u0644\u0645\u062a\u063a\u064a\u0631 \u0627\u0644\u062b\u0627\u0628\u062a static \u0627\u0644\u0645\u0639\u0644\u0646 \u062f\u0627\u062e\u0644 \u0627\u0644\u062f\u0627\u0644\u0629 \u0639\u0644\u0649 \u062a\u0644\u0643 \u0627\u0644\u062f\u0627\u0644\u0629. \u0648\u0644\u0627 \u064a\u0645\u0643\u0646 \u0627\u0644\u0648\u0635\u0648\u0644 \u0625\u0644\u064a\u0647 \u0645\u0646 \u062e\u0627\u0631\u062c \u0627\u0644\u062f\u0627\u0644\u0629. \u0641\u064a \u0647\u0630\u0627 \u0627\u0644\u0645\u062b\u0627\u0644\u060c \u0644\u0627 \u064a\u0645\u0643\u0646 \u0627\u0644\u0648\u0635\u0648\u0644 \u0625\u0644\u0649 x \u0625\u0644\u0627 \u0645\u0646 \u062e\u0644\u0627\u0644 \u0627\u0644\u062f\u0627\u0644\u0629 f().<\/li>\n<\/ol>\n<h1>Static Class Member<\/h1>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">#include &lt;iostream&gt;\r\n#include &lt;cstring&gt;\r\n#include &lt;string&gt;\r\nusing namespace std;\r\n\/\/define how many objects are created \r\nclass Student {\r\n        static int count;\r\n        char name[20];\r\n        int first, second, final, total, ID;\r\n    public:\r\n        Student() \/\/constructor \r\n        {\r\n            strcpy(name, \"No name\");\r\n            ID = 0;\r\n            first = second = final = 0;\r\n            count++;\r\n            cout &lt;&lt; \"Numbers of students constructed: \" &lt;&lt; count &lt;&lt; endl;\r\n        }\r\n}; \/\/end of class\r\nint Student::count = 0;\r\nint main()\r\n{\r\n    cout &lt;&lt; \"\\nConstruct 2 objects\\n\";\r\n    Student S1, S2;\r\n    cout &lt;&lt; \"\\nConstruct 3 objects\\n\";\r\n    Student St[3];\r\n    return 0;\r\n} \/\/end of main<\/pre>\n<p>\u2013 \u062a\u0639\u0631\u064a\u0641 \u0627\u0644\u0640(Class): Student<\/p>\n<ul>\n<li>\u064a\u0639\u0631\u0641 class Student \u0628\u0623\u0633\u0645\u0627\u0621 \u0623\u0639\u0636\u0627\u0621 \u0627\u0644\u0628\u064a\u0627\u0646\u0627\u062a \u0627\u0644\u062e\u0627\u0635\u0629\u060c first, second, final, total, \u0648ID<\/li>\n<li>\u062a\u0645 \u062a\u0639\u0631\u064a\u0641 \u0645\u062a\u063a\u064a\u0631 \u0627\u0644\u0639\u062f\u062f \u0639\u0644\u0649 \u0623\u0646\u0647 static \u062f\u0627\u062e\u0644 \u0627\u0644\u0643\u0644\u0627\u0633. \u0648\u0647\u0630\u0627 \u064a\u0639\u0646\u064a \u0623\u0646\u0647 \u0645\u0634\u062a\u0631\u0643 \u0628\u064a\u0646 \u062c\u0645\u064a\u0639 \u0643\u0627\u0646\u0627\u062a Student class\u060c \u0648\u062a\u0633\u062a\u0645\u0631 \u0642\u064a\u0645\u062a\u0647\u0627 \u0639\u0628\u0631 \u0643\u0627\u0626\u0646\u0627\u062a Student \u0627\u0644\u0645\u062a\u0639\u062f\u062f\u0629.<\/li>\n<\/ul>\n<p>\u0623\u062f\u0627\u0629 \u0627\u0644\u0628\u0646\u0627\u0621 Constructor:<\/p>\n<ul>\n<li>\u064a\u062d\u062a\u0648\u064a \u0627\u0644\u0643\u0644\u0627\u0633 \u0639\u0644\u0649 \u0623\u062f\u0627\u0629 \u0627\u0644\u0628\u0646\u0627\u0621 \u0627\u0644\u0627\u0641\u062a\u0631\u0627\u0636\u064a\u0629 Student() \u0627\u0644\u0630\u064a \u064a\u0642\u0648\u0645 \u0628\u062a\u0647\u064a\u0626\u0629 \u0623\u0639\u0636\u0627\u0621 \u0627\u0644\u0628\u064a\u0627\u0646\u0627\u062a \u0628\u0627\u0644\u0642\u064a\u0645 \u0627\u0644\u0627\u0641\u062a\u0631\u0627\u0636\u064a\u0629.<\/li>\n<li>\u0641\u064a constructor\u060c \u064a\u062a\u0645 \u062a\u0647\u064a\u0626\u0629 name \u0628\u0640\"No name\"\u060c \u0648\u064a\u062a\u0645 \u062a\u0647\u064a\u0626\u0629 ID \u0628\u0640 0\u060c \u0648\u064a\u062a\u0645 \u062a\u0647\u064a\u0626\u0629 exam scores \u0628\u0640 0.<\/li>\n<li>\u0641\u064a \u0643\u0644 \u0645\u0631\u0629 \u064a\u062a\u0645 \u0625\u0646\u0634\u0627\u0621 Student object\u060c \u062a\u062a\u0645 \u0632\u064a\u0627\u062f\u0629 \u0645\u062a\u063a\u064a\u0631 \u0627\u0644\u0639\u062f\u062f\u060c \u0648\u062a\u062a\u0645 \u0637\u0628\u0627\u0639\u0629 \u0627\u0644\u0639\u062f\u062f \u0627\u0644\u0625\u062c\u0645\u0627\u0644\u064a \u0644\u0644\u0637\u0644\u0627\u0628 \u0627\u0644\u0630\u064a\u0646 \u062a\u0645 \u0625\u0646\u0634\u0627\u0624\u0647\u0645.<\/li>\n<\/ul>\n<p>\u062a\u0647\u064a\u0626\u0629 \u0627\u0644\u0640 Static Member:<\/p>\n<ul>\n<li>\u062a\u062a\u0645 \u062a\u0647\u064a\u0626\u0629 static member \u062e\u0627\u0631\u062c \u062a\u0639\u0631\u064a\u0641 class.<\/li>\n<\/ul>\n<p>\u0627\u0644\u062f\u0627\u0644\u0629 \u0627\u0644\u0631\u0626\u064a\u0633\u0629 main:<\/p>\n<ul>\n<li>\u0641\u064a \u0627\u0644\u062f\u0627\u0644\u0629 main()\u060c \u064a\u062a\u0645 \u0625\u0646\u0634\u0627\u0621 \u0643\u0627\u0626\u0646\u064a\u0646 \u0644\u0644\u0640Student (S1 \u0648S2) \u0628\u0627\u0633\u062a\u062e\u062f\u0627\u0645 \u0627\u0644\u0640default constructor. \u064a\u0642\u0648\u0645 \u0627\u0644\u0628\u0631\u0646\u0627\u0645\u062c \u0628\u0637\u0628\u0627\u0639\u0629 \u0639\u062f\u062f \u0627\u0644\u0637\u0644\u0627\u0628 \u0627\u0644\u0630\u064a\u0646 \u062a\u0645 \u0625\u0646\u0634\u0627\u0624\u0647\u0645 \u0628\u0639\u062f \u0625\u0646\u0634\u0627\u0621 \u0643\u0644 \u0643\u0627\u0626\u0646.<\/li>\n<li>\u0628\u0639\u062f \u0630\u0644\u0643\u060c \u064a\u062a\u0645 \u0625\u0646\u0634\u0627\u0621 \u0645\u0635\u0641\u0648\u0641\u0629 \u0645\u0643\u0648\u0646\u0629 \u0645\u0646 \u062b\u0644\u0627\u062b\u0629 \u0643\u0627\u0626\u0646\u0627\u062a \u0644\u0644\u0640Student. \u0645\u0631\u0629 \u0623\u062e\u0631\u0649\u060c \u064a\u0642\u0648\u0645 \u0627\u0644\u0628\u0631\u0646\u0627\u0645\u062c \u0628\u0637\u0628\u0627\u0639\u0629 \u0639\u062f\u062f \u0627\u0644\u0637\u0644\u0627\u0628 \u0627\u0644\u0630\u064a\u0646 \u062a\u0645 \u0625\u0646\u0634\u0627\u0624\u0647\u0645 \u0628\u0639\u062f \u0625\u0646\u0634\u0627\u0621 \u0647\u0630\u0647 \u0627\u0644\u0645\u0635\u0641\u0648\u0641\u0629.<\/li>\n<\/ul>\n<p>\u0627\u0644\u0645\u062e\u0631\u062c\u0627\u062a:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">Construct 2 objects\r\nNumbers of students constructed: 1\r\nNumbers of students constructed: 2\r\n\r\nConstruct 3 objects\r\nNumbers of students constructed: 3\r\nNumbers of students constructed: 4\r\nNumbers of students constructed: 5<\/pre>\n<p>\u064a\u062a\u0645 \u0627\u0633\u062a\u062e\u062f\u0627\u0645 \u0645\u062a\u063a\u064a\u0631 \u0627\u0644\u0640 static member \u0644\u062a\u062a\u0628\u0639 \u0627\u0644\u0639\u062f\u062f \u0627\u0644\u0625\u062c\u0645\u0627\u0644\u064a \u0644\u0643\u0627\u0626\u0646\u0627\u062a \u0627\u0644\u0640Student \u0627\u0644\u062a\u064a \u062a\u0645 \u0625\u0646\u0634\u0627\u0624\u0647\u0627. \u0641\u064a \u0643\u0644 \u0645\u0631\u0629 \u064a\u062a\u0645 \u0641\u064a\u0647\u0627 \u0625\u0646\u0634\u0627\u0621 \u0643\u0627\u0626\u0646 \u0627\u0644\u0637\u0627\u0644\u0628 (\u0623\u064a \u0639\u0646\u062f \u0627\u0633\u062a\u062f\u0639\u0627\u0621 \u0627\u0644\u0640constructor)\u060c \u064a\u0632\u062f\u0627\u062f \u0627\u0644\u0639\u062f\u062f. \u064a\u0633\u0645\u062d \u0647\u0630\u0627 \u0644\u0644\u0628\u0631\u0646\u0627\u0645\u062c \u0628\u062a\u062a\u0628\u0639 \u0639\u062f\u062f \u0643\u0627\u0626\u0646\u0627\u062a \u0627\u0644\u0637\u0627\u0644\u0628 \u0627\u0644\u062a\u064a \u062a\u0645 \u0625\u0646\u0634\u0627\u0621 \u0645\u062b\u064a\u0644 \u0644\u0647\u0627 \u0639\u0628\u0631 \u062a\u0646\u0641\u064a\u0630 \u0627\u0644\u0628\u0631\u0646\u0627\u0645\u062c \u0628\u0623\u0643\u0645\u0644\u0647.<\/p>\n<h1>Static Member Function<\/h1>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">#include &lt;iostream&gt;\r\n#include &lt;cstring&gt;\r\n#include &lt;string&gt;\r\nusing namespace std;\r\nclass Student {\r\n        static int count;\r\n        char name[20];\r\n        int first, second, final, total, ID;\r\n    public:\r\n        static void print_count()\r\n        {\r\n            cout &lt;&lt; \"Students constructed: \" &lt;&lt; count &lt;&lt; endl;\r\n        }\r\n        Student() \/\/constructor \r\n        {\r\n            strcpy(name, \"No name\");\r\n            ID = 0;\r\n            first = second = final = 0;\r\n            count++;\r\n            print_count();\r\n        }\r\n}; \/\/end of class\r\nint Student::count = 0;\r\nint main()\r\n{\r\n    Student::print_count();\r\n    cout &lt;&lt; \"\\nConstruct 2 objects\\n\";\r\n    Student S1, S2;\r\n    cout &lt;&lt; \"\\nConstruct 3 objects\\n\";\r\n    Student St[3];\r\n    return 0;\r\n} \/\/end of main\r\n<\/pre>\n<p>\u0641\u064a \u0647\u0630\u0627 \u0627\u0644\u0628\u0631\u0646\u0627\u0645\u062c \u0627\u0644\u0630\u064a \u062a\u0645 \u062a\u062d\u062f\u064a\u062b\u0647\u060c \u062a\u0645\u062a \u0625\u0636\u0627\u0641\u0629 \u0648\u0638\u064a\u0641\u0629 \u0627\u0644\u0639\u0636\u0648 (static ) print_count() \u0625\u0644\u0649 \u0641\u0626\u0629 \u0627\u0644\u0637\u0627\u0644\u0628. \u0625\u0644\u064a\u0643 \u0645\u0627 \u062a\u0641\u0639\u0644\u0647 \u0627\u0644\u0643\u0644\u0645\u0629 \u0627\u0644\u0623\u0633\u0627\u0633\u064a\u0629 static  \u0641\u064a \u0647\u0630\u0627 \u0627\u0644\u0633\u064a\u0627\u0642:<\/p>\n<ul>\n<li>Static Member Function: \u062a\u0645 \u062a\u0639\u0631\u064a\u0641 \u062f\u0627\u0644\u0629 \u0627\u0644\u0639\u0636\u0648 print_count() \u0639\u0644\u0649 \u0623\u0646\u0647\u0627 static. \u0648\u0647\u0630\u0627 \u064a\u0639\u0646\u064a \u0623\u0646\u0647 \u064a\u0646\u062a\u0645\u064a \u0625\u0644\u0649 \u0627\u0644\u0641\u0626\u0629 \u0646\u0641\u0633\u0647\u0627\u060c \u0648\u0644\u064a\u0633 \u0625\u0644\u0649 \u0627\u0644\u0645\u062b\u064a\u0644\u0627\u062a \u0627\u0644\u0641\u0631\u062f\u064a\u0629 (\u0627\u0644\u0643\u0627\u0626\u0646\u0627\u062a) \u0644\u0644\u0641\u0626\u0629. \u0644\u0627 \u062a\u062a\u0645\u062a\u0639 \u062f\u0648\u0627\u0644 \u0627\u0644\u0623\u0639\u0636\u0627\u0621 \u0627\u0644\u0640static \u0628\u0625\u0645\u0643\u0627\u0646\u064a\u0629 \u0627\u0644\u0648\u0635\u0648\u0644 \u0625\u0644\u0649 \u0645\u062a\u063a\u064a\u0631\u0627\u062a \u0623\u0648 \u062f\u0648\u0627\u0644 \u0627\u0644\u0623\u0639\u0636\u0627\u0621 \u063a\u064a\u0631 \u0627\u0644\u0640static \u0645\u0628\u0627\u0634\u0631\u0629 \u0644\u0623\u0646\u0647\u0627 \u063a\u064a\u0631 \u0645\u0631\u062a\u0628\u0637\u0629 \u0628\u0623\u064a \u0643\u0627\u0626\u0646 \u0645\u0639\u064a\u0646.<\/li>\n<li>\u0627\u0644\u0648\u0635\u0648\u0644 \u0625\u0644\u0649 \u0645\u062a\u063a\u064a\u0631\u0627\u062a \u0627\u0644\u0623\u0639\u0636\u0627\u0621 \u0627\u0644\u0640Static: \u062f\u0627\u062e\u0644 \u062f\u0627\u0644\u0629 \u0627\u0644\u0639\u0636\u0648 \u0627\u0644\u062b\u0627\u0628\u062a print_count()\u060c \u064a\u062a\u0645 \u0627\u0644\u0648\u0635\u0648\u0644 \u0625\u0644\u0649 \u0639\u062f\u062f \u0645\u062a\u063a\u064a\u0631\u0627\u062a \u0627\u0644\u0623\u0639\u0636\u0627\u0621 \u0627\u0644\u0640\u0640static \u0645\u0628\u0627\u0634\u0631\u0629. \u0648\u0628\u0645\u0627 \u0623\u0646 \u0627\u0644\u0639\u062f \u0647\u0648 \u0623\u064a\u0636\u064b\u0627 static\u060c \u0641\u064a\u0645\u0643\u0646 \u0627\u0644\u0648\u0635\u0648\u0644 \u0625\u0644\u064a\u0647 \u062f\u0648\u0646 \u0627\u0644\u062d\u0627\u062c\u0629 \u0625\u0644\u0649 \u0645\u062b\u064a\u0644 \u0644\u0644\u0641\u0626\u0629.<\/li>\n<li>\u0627\u0644\u0648\u0635\u0648\u0644 \u0625\u0644\u0649 \u062f\u0627\u0644\u0629 \u0627\u0644\u0639\u0636\u0648 \u0627\u0644\u0640Static: \u064a\u0645\u0643\u0646 \u0627\u0633\u062a\u062f\u0639\u0627\u0621 \u062f\u0648\u0627\u0644 \u0627\u0644\u0639\u0636\u0648 \u0627\u0644\u0640Static \u0628\u0627\u0633\u062a\u062e\u062f\u0627\u0645 \u0627\u0633\u0645 \u0627\u0644\u0643\u0644\u0627\u0633 \u0645\u062a\u0628\u0648\u0639\u064b\u0627 \u0628\u0639\u0627\u0645\u0644 \u062a\u062d\u0644\u064a\u0644 \u0627\u0644\u0646\u0637\u0627\u0642 (::). \u0639\u0644\u0649 \u0633\u0628\u064a\u0644 \u0627\u0644\u0645\u062b\u0627\u0644\u060c \u064a\u0633\u062a\u062f\u0639\u064a Student::print_count() \u0627\u0644\u062f\u0627\u0644\u0629 print_count() \u0627\u0644\u062e\u0627\u0635\u0629 \u0628\u0643\u0644\u0627\u0633 Student .<\/li>\n<li>\u0627\u0644\u0627\u0633\u062a\u062e\u062f\u0627\u0645: \u0641\u064a \u0627\u0644\u062f\u0627\u0644\u0629 main()\u060c \u064a\u062a\u0645 \u0627\u0633\u062a\u062f\u0639\u0627\u0621 Student::print_count() \u0642\u0628\u0644 \u0625\u0646\u0634\u0627\u0621 \u0623\u064a \u0643\u0627\u0626\u0646\u0627\u062a Student. \u064a\u0648\u0636\u062d \u0647\u0630\u0627 \u0623\u0646\u0647 \u064a\u0645\u0643\u0646 \u0627\u0633\u062a\u062f\u0639\u0627\u0621 \u062f\u0648\u0627\u0644 \u0627\u0644\u0623\u0639\u0636\u0627\u0621 \u0627\u0644\u0640static \u062f\u0648\u0646 \u0627\u0644\u062d\u0627\u062c\u0629 \u0625\u0644\u0649 \u0625\u0646\u0634\u0627\u0621 \u0645\u062b\u064a\u0644 \u0644\u0644\u0643\u0627\u0626\u0646.<\/li>\n<li>\u0627\u0644\u062a\u0647\u064a\u0626\u0629 \u0648\u0627\u0644\u0632\u064a\u0627\u062f\u0629: \u062f\u0627\u062e\u0644 Student constructor\u060c \u062a\u062a\u0645 \u0632\u064a\u0627\u062f\u0629 \u0645\u062a\u063a\u064a\u0631 \u0627\u0644\u0639\u062f\u062f \u0641\u064a \u0643\u0644 \u0645\u0631\u0629 \u064a\u062a\u0645 \u0641\u064a\u0647\u0627 \u0625\u0646\u0634\u0627\u0621 \u0643\u0627\u0626\u0646 \u0637\u0627\u0644\u0628 \u062c\u062f\u064a\u062f. \u064a\u062a\u0645 \u0627\u0633\u062a\u062f\u0639\u0627\u0621 \u0627\u0644\u062f\u0627\u0644\u0629 print_count() \u062f\u0627\u062e\u0644 \u0627\u0644\u0645\u0646\u0634\u0626 \u0644\u0639\u0631\u0636 \u0627\u0644\u0639\u062f\u062f \u0627\u0644\u0645\u062d\u062f\u062b \u0628\u0639\u062f \u0643\u0644 \u0625\u0646\u0634\u0627\u0621 \u0644\u0644\u0643\u0627\u0626\u0646.<\/li>\n<\/ul>\n<p>\u064a\u0648\u0636\u062d \u0647\u0630\u0627 \u0627\u0644\u0628\u0631\u0646\u0627\u0645\u062c \u0627\u0633\u062a\u062e\u062f\u0627\u0645 \u062f\u0627\u0644\u0629 \u0639\u0636\u0648 static \u0644\u0644\u0648\u0635\u0648\u0644 \u0625\u0644\u0649 \u0645\u062a\u063a\u064a\u0631 \u0639\u0636\u0648 static \u0648\u062a\u0648\u0641\u064a\u0631 \u0627\u0644\u062f\u0648\u0627\u0644 \u0627\u0644\u0645\u0631\u062a\u0628\u0637\u0629 \u0628\u0627\u0644\u0641\u0626\u0629 \u0646\u0641\u0633\u0647\u0627\u060c \u0628\u062f\u0644\u0627\u064b \u0645\u0646 \u0627\u0644\u0643\u0627\u0626\u0646\u0627\u062a \u0627\u0644\u0641\u0631\u062f\u064a\u0629 \u0644\u0644\u0641\u0626\u0629.<\/p>","protected":false},"excerpt":{"rendered":"<p>Introduction In C++, &#8220;static class members&#8221; and &#8220;static member functions&#8221; introduce class-level elements that are not associated with individual objects of the class. #include &lt;iostream&gt; #include &lt;string&gt; using namespace std; void f() { static int x = 0; x++; cout &lt;&lt; x &lt;&lt; endl; } int main() { f(); f(); return 0; } This C++ [&hellip;]<\/p>","protected":false},"author":3,"featured_media":0,"parent":4291,"menu_order":48,"comment_status":"closed","ping_status":"closed","template":"","doc_tag":[],"class_list":["post-10664","docs","type-docs","status-publish","hentry","no-post-thumbnail"],"acf":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/adelnasim.com\/ar\/wp-json\/wp\/v2\/docs\/10664","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=10664"}],"version-history":[{"count":7,"href":"https:\/\/adelnasim.com\/ar\/wp-json\/wp\/v2\/docs\/10664\/revisions"}],"predecessor-version":[{"id":10674,"href":"https:\/\/adelnasim.com\/ar\/wp-json\/wp\/v2\/docs\/10664\/revisions\/10674"}],"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=10664"}],"wp:term":[{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/adelnasim.com\/ar\/wp-json\/wp\/v2\/doc_tag?post=10664"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}