Presentation is loading. Please wait.

Presentation is loading. Please wait.

برنامه نويسي پيشرفته مقدمه By: Ali Bazghandi. C++ Programming: Ali Bazghandi2 نکات مهم مراجع C++ FOR DUMMIES 5TH EDITION by Stephen Randy Davis PROGRAMMING.

Similar presentations


Presentation on theme: "برنامه نويسي پيشرفته مقدمه By: Ali Bazghandi. C++ Programming: Ali Bazghandi2 نکات مهم مراجع C++ FOR DUMMIES 5TH EDITION by Stephen Randy Davis PROGRAMMING."— Presentation transcript:

1 برنامه نويسي پيشرفته مقدمه By: Ali Bazghandi

2 C++ Programming: Ali Bazghandi2 نکات مهم مراجع C++ FOR DUMMIES 5TH EDITION by Stephen Randy Davis PROGRAMMING WITH C++ by JOHN R. HUBBARD, Ph.D. (SCHAUM’S OUTLINE) ارزشيابي دانشجويان −تکاليف و کلاسي −پروژه −ميانترم −پايان ترم

3 C++ Programming: Ali Bazghandi3 C++ تاريخچه زبان C++ was written by Bjarne Stroustrup at Bell Labs during 1983- 1985. C++ is an extension of C. Prior to 1983, Bjarne Stroustrup added features to C and formed what he called "C with Classes". He had combined the Simula's use of classes and object-oriented features with the power and efficiency of C. The term C++ was first used in 1983.Bjarne StroustrupSimula Bjarne Stroustrup Dennis MacAlistair Ritchie

4 C++ Programming: Ali Bazghandi4 C++ was developed significantly after its first release.1 In particular, "ARM C++" added exceptions and templates, and ISO C++ added RTTI, namespaces, and a standard library.1 C++ was designed for the UNIX system environment. With C++ programmers could improve the quality of code they produced and reusable code was easier to write.

5 C++ Programming: Ali Bazghandi5 Bjarne Stroustrup had studied in the doctoral program at the Computing Laboratory at Cambridge University prior to joining Bell Labs. Now, Bell Labs no longer has that name since part of Bell Labs became AT&T Labs. The other half became Lucent Bell labs.AT&T Labs Prior to C++, C was a programming language developed at Bell Labs circa 1969-1973. The UNIX operating system was also being developed at Bell Labs at the same time. C was originally developed for and implemented on the UNIX operating system, on a PDP-11 computer by Dennis Ritchie.Dennis Ritchie

6 C++ Programming: Ali Bazghandi6 He extended the B language by adding types in 1971. He called this NB for New B. Ritchie credited some of his inspiration from theAlgol68 language. Ritchie restructured the language and rewrote the compiler and gave his new language the name "C" in 1972. 90% of UNIX was then written in C. The committee that wrote the 1989 ANSI Standard for C had started work on the C Standard project in 1983 after having been established by ANSI in that year. There were quite a number of versions of C at that time and a new Standard was necessary.Algol68

7 C++ Programming: Ali Bazghandi7 C is portable, not tied to any particular hardware or operating system. C combines the elements of high- level languages with the functionality of assembly language and has occasionally been referred to as a middle-level computer language. C makes it easy to adapt software for one type of computer to another. C was a direct descendant of the language B. The language B was developed by Ken Thompson in 1970 for the new UNIX OS. B was a descendant of the language BCPL designed by Martin Richards, a Cambridge University student visiting MIT.1Ken ThompsonMartin Richards

8 C++ Programming: Ali Bazghandi8 Ken Thompson Martin Richards

9 C++ Programming: Ali Bazghandi9 ويژگي هاي C++ C++ يک زبان شي گراست. C++ يک زبان سطح پايين و استاندارد ISO و ANSI است. با وجود تشابه به زبانهاي سطح پايين مانند C برنامه هاي بسيار کارا و سريع توليد مي کند. به عنوان يک زبان شي گرا داراي قدرت توسعه جهت نوشتن برنامه هاي با مقياس بزرگ را داراست. يکي از مشهورترين زبانهاست که بيشتر برنامه هاي روي سيستم شما به اين زبان نوشته شده اند. از آنجاييکه داراي استاندارد تضمين شده است داراي قابليت حمل مي باشد. هر سيستم عامل مهم کامپايلري براي زبان C++ دارد.

10 C++ Programming: Ali Bazghandi10 برنامه چيست؟ يک برنامه C++ يک فايل متني است که شامل ترتيبي از دستورات C++ مي باشد که بر طبق گرامر C++ کنار هم قرار گرفته اند. اين فايل متني به عنوان فايل منبع شناخته مي شود. اين فايل منبع بنا به قارداد داراي پسوند cpp است. يک کامپايلر برنامه نوشته شده به زبان سطح بالا را به زبان ماشين ترجمه مي کند.

11 C++ Programming: Ali Bazghandi11 ساختمان کامپيوتر

12 C++ Programming: Ali Bazghandi12 پردازش يک برنامه C++ [1] براي اجراي يک برنامه نوشته شده به زبان سطح بالا مانند C++ −از يک ويرايشگر براي ايجاد برنامه استفاده مي کنيم. −جملاتي از برنامه که علامت # دارد بوسيله برنامه پيش پردازشگر پردازش مي شود. −از يک کامپايلر براي تست گرامر و تبديل برنامه به زبان ماشين استفاده مي شود. −لينک کننده: ترکيب برنامه شي با ديگر برنامه هاي توليد شده SDK براي توليد کد اجرايي −لود کننده: لود برنامه قابل اجرا به حافظه اصلي −آخرين مرحله اجراي برنامه است.

13 C++ Programming: Ali Bazghandi13 پردازش يک برنامه C++ [2]

14 C++ Programming: Ali Bazghandi14 Problem Solving Process Step 1 - Analyze the problem −Outline the problem and its requirements −Design steps (algorithm) to solve the problem Step 2 - Implement the algorithm −Implement the algorithm in code −Verify that the algorithm works Step 3 - Maintenance −Use and modify the program if the problem domain changes

15 C++ Programming: Ali Bazghandi15

16 C++ Programming: Ali Bazghandi16 يک برنامه C++ // my first program in C++ #include //#include using namespace std; //omitted int main () { cout <<"Hello World!"; return 0; } Output: Hello World!

17 C++ Programming: Ali Bazghandi17 يک برنامه ديگر C++ #include using namespace std; int main() { cout << "My first C++ program." << endl; cout << "The sum of 2 and 3 = " << 5 << endl; cout << "7 + 8 = " << 7 + 8 << endl; return 0; } Sample Run: My first C++ program. The sum of 2 and 3 = 5 7 + 8 = 15

18 C++ Programming: Ali Bazghandi18 نکته ها [ 1] : C++ حساس به حرف است ( تفاوت بين حرف کوچک و بزرگ ) تعداد کلمات کليدي ( رزرو شده براي هدف خاص ) 48 کلمه است :

19 C++ Programming: Ali Bazghandi19 نکته ها [ 2] : C++ حساس به حرف است ( تفاوت بين حرف کوچک و بزرگ ) دستورات به ; ختم مي شوند. هر دستور مي تواند در چند سطر ادامه يابد. در هر سط مي توان چند دستور را تايپ کرد. توضيحات (comments) − // comment − /* comment */ فايلهاي سرآيند (header files) فضاهاي اسمي (namespaces)

20 C++ Programming: Ali Bazghandi20 فايلهاي سرآيند :

21 C++ Programming: Ali Bazghandi21 فضاي اسمي [ 1] : امکان جديد در C++ که برخي کامپايلرها آنرا پشتيباني نمي کنند. يک ناحيه تعريفي را ايجاد مي کند که عناصر مختلف برنامه مي توانند در آن قرار گيرند. اجازه گروهبندي موجوديت هايي مانند: کلاسها، اشيا و توابع را تحت يک نام مي دهند. اين امر امکان تقسيم بندي فضاي کلي را به چند زير فضاي داراي نام مي دهد.

22 C++ Programming: Ali Bazghandi22 فضاي اسمي [ 2] : نحوه تعريف فضاي اسمي: namespace identifier { entities } مثال: namespace myNamespace { int a, b; } نحوه دسترسي از خارج فضاي اسمي: myNamespace::a myNamespace::b

23 C++ Programming: Ali Bazghandi23 فضاي اسمي [ 3] : مثال: #include using namespace std; namespace first { int var = 5; } namespace second { double var = 3.1416; } int main () { cout << first::var << endl; cout << second::var << endl; return 0; }

24 C++ Programming: Ali Bazghandi24 فضاي اسمي [ 4] : مثال: #include using namespace std; namespace first { int x = 5; int y = 10; } namespace second { double x = 3.1416; double y = 2.7183; } int main () { using first::x; using second::y; cout << x << endl; cout << y << endl; cout << first::y << endl; cout << second::x << endl; return 0; }

25 C++ Programming: Ali Bazghandi25 فضاي اسمي [ 5] : مثال: #include using namespace std; namespace first { int x = 5; int y = 10; } namespace second { double x = 3.1416; double y = 2.7183; } int main () { using namespace first; cout << x << endl; cout << y << endl; cout << second::x << endl; cout << second::y << endl; return 0; }

26 C++ Programming: Ali Bazghandi26 فضاي اسمي [ 6] : مثال: #include using namespace std; namespace first { int x = 5; } namespace second { double x = 3.1416; } int main () { using namespace first; cout << x << endl; } { using namespace second; cout << x << endl; } return 0; }

27 C++ Programming: Ali Bazghandi27 متغيرها (variables): همان مفهوم متغير در رياضيات است که براي نگهداري مثلا يک عدد در يک محل فرضي استفاده مي شود. X=1 اما: (x + 2) = y / 2 x + 4 = y solve for x and y انواع متغير: x = 1 x = 2.3 x = “this is a sentence” x = Texas

28 C++ Programming: Ali Bazghandi28 انواع متغيرها :

29 C++ Programming: Ali Bazghandi29 محدوده متغيرها [ 1] : #include // Prints the constants stored in limits.h: Main() { cout << "minimum char = ' cc CHAR-MIN << endl; cout << "maximum char = ' << CHAR-MAX << endl; cout << "minimum short = ' << SHRT-MIN << endl; cout << "maximum short = ' cc SHRTJAX << endl; cout << "minimum int = ' cc INT-MIN << endl; cout << "maximum int = ' << INTJLAX << endl; cout << "minimum long = ' << LONG-MIN << endl; cout << "maximum long = 'I << LONG-MAX << endl; cout << "minimum signed char = ' cc SCHAR MIN << endl; - cout << "maximum signed char = ' -cc SCHARJAX << endl; cout << "maximum unsigned char = ' cc UCHARJAX << endl; cout << "maximum unsigned short = ' c-c USHRTJAX << endl; cout << "maximum unsigned = << UINT-MAX << endl; cout << "maximum unsigned long = ' << ULONGJAX << endl; return 0; {

30 C++ Programming: Ali Bazghandi30 محدوده متغيرها [ 2] : minimum char = -128 maximum char = 127 minimum short = -32768 maximum short = 32767 minimum int = -2147483648 maximum int = 2147483647 minimum long = -2147483648 maximum long = 2147483647 minimum signed char = -128 maximum signed char = 127 maximum unsigned char = 255 maximum unsigned short = 65535 maximum unsigned = 4294967295 maximum unsigned long = 4294967295

31 C++ Programming: Ali Bazghandi31 char short int unsigned char unsigned short unsigned range -128 to 127 (1 byte) range -32,768 to 32,767 (2 bytes) range -2,147,483,648 to 2,147,483,647 (4 bytes) range 0 to 255 (1 byte) range 0 to 65,535 (2 bytes) range 0 to 4,294,967,295 (4 bytes)

32 C++ Programming: Ali Bazghandi32 ANSI-C ANSI-C++ ANSI-C ANSI-C++ ANSI-C ANSI-C++


Download ppt "برنامه نويسي پيشرفته مقدمه By: Ali Bazghandi. C++ Programming: Ali Bazghandi2 نکات مهم مراجع C++ FOR DUMMIES 5TH EDITION by Stephen Randy Davis PROGRAMMING."

Similar presentations


Ads by Google