C/C++ <ul><li>By </li></ul><ul><li>Abdallah Abuouf </li></ul><ul><li>3 rd  IT </li></ul><ul><li>[email_address] </li></ul>
Agenda <ul><li>Why c++ </li></ul><ul><li>Basics </li></ul><ul><li>Pointer </li></ul><ul><li>Oop </li></ul><ul><li>Data str...
Why C++ ?!! <ul><li>Pointer -> The power </li></ul><ul><li>Oop  -> Ease of understanding and clarity  </li></ul><ul><li>Me...
Basics <ul><li>Data type </li></ul><ul><li>Commentes </li></ul><ul><li>Functions </li></ul><ul><li>Special symbols </li></ul>
Data type <ul><li>Int   4byte </li></ul><ul><li>Double 8byte </li></ul><ul><li>Float 4byte </li></ul><ul><li>Char 1byte </...
Functions <ul><li>return_type function_name(args); </li></ul><ul><li>main(){ </li></ul><ul><li>function_name(); </li></ul>...
Another way <ul><li>return_type function_name(args) </li></ul><ul><li>{ </li></ul><ul><li>//statements </li></ul><ul><li>}...
Special symbols <ul><li>
 new line </li></ul><ul><li> backspace </li></ul><ul><li>	 tab </li></ul><ul><li>
 start of line...
Conditions <ul><li>If esle </li></ul><ul><li>Switch case </li></ul>
If else <ul><li>if(condition){ </li></ul><ul><li>//statments </li></ul><ul><li>} </li></ul><ul><li>Else{ </li></ul><ul><li...
Switch case <ul><li>switch c{ </li></ul><ul><li>case a: </li></ul><ul><li>//statements;  </li></ul><ul><li>break; </li></u...
Loops  <ul><li>For loop </li></ul><ul><li>While </li></ul><ul><li>Do while </li></ul><ul><li>Goto </li></ul><ul><li>Break ...
For loop <ul><li>Nested for </li></ul><ul><li>for(int i=1;i<10;i++){ </li></ul><ul><li>for(int j=1;j<=i;j++){ </li></ul><u...
while <ul><li>while(condition) </li></ul><ul><li>{ </li></ul><ul><li>//statments </li></ul><ul><li>} </li></ul>
Do while <ul><li>{ </li></ul><ul><li>//statmentes </li></ul><ul><li>}dowhile(condition) </li></ul>
GO TO <ul><li>a:  //label </li></ul><ul><li>//statments </li></ul><ul><li>if(condition){ </li></ul><ul><li>goto a; </li></...
Pointer is very easy <ul><li>int *xadd; </li></ul><ul><li>int x=7;  --->(1) </li></ul><ul><li>int y=x;  --->(2) </li></ul>...
<ul><li>Data type  *pointer _name; </li></ul><ul><li>pointer _name=&variable name </li></ul><ul><li>Data type  &Reference ...
Pointer Ex  <ul><li>int x=5;  </li></ul><ul><li>int y=105;  </li></ul><ul><li>int *p1=&x;  </li></ul><ul><li>int *p2=&y;  ...
Reference Ex <ul><li>int x=300;  </li></ul><ul><li>int &ref=x;  </li></ul><ul><li>cout<<&quot; x= &quot;<<x;  </li></ul><u...
Oop  <ul><li>Constractor & destractor </li></ul><ul><li>Class </li></ul><ul><li>Header file </li></ul>
Demo
Data structure <ul><li>Array </li></ul><ul><li>Linked list </li></ul>
Array  <ul><li>Data type array_name[size]; </li></ul><ul><li>Multidimensional Arrays  </li></ul><ul><li>Data type array_na...
Linked list  <ul><li>Demo </li></ul>
C/C++ under Linux  <ul><li>Install on debian family </li></ul><ul><li>sudo apt-get install gcc </li></ul><ul><li>Install o...
Make executable file <ul><li>Change the extension of complied file to .sh </li></ul><ul><li>then click on it ,it will run ...
Create GUI by GTK+ <ul><li>It's work under Linux and windows </li></ul><ul><li>Very beautiful </li></ul><ul><li>Free  </li...
C++ and netbeans Demo
 
References  <ul><li>Robert_Lafore-Object_Oriented_Programming_in_C++ </li></ul><ul><li>Data Structures and Algorithm Analy...
With best wishes Abuouf http://abuouf.wordpress.com [email_address]
Upcoming SlideShare
Loading in...5
×

C++ programming

1,068

Published on

Published in: Education
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,068
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
65
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

C++ programming

  1. 1. C/C++ <ul><li>By </li></ul><ul><li>Abdallah Abuouf </li></ul><ul><li>3 rd IT </li></ul><ul><li>[email_address] </li></ul>
  2. 2. Agenda <ul><li>Why c++ </li></ul><ul><li>Basics </li></ul><ul><li>Pointer </li></ul><ul><li>Oop </li></ul><ul><li>Data structure </li></ul><ul><li>C/C++ under Linux </li></ul><ul><li>Create GUI by GTK+ </li></ul><ul><li>C++ and netbeans </li></ul>
  3. 3. Why C++ ?!! <ul><li>Pointer -> The power </li></ul><ul><li>Oop -> Ease of understanding and clarity </li></ul><ul><li>Memory Controller -> Good but dangerous </li></ul><ul><li>All -> Fun and simple :) </li></ul>
  4. 4. Basics <ul><li>Data type </li></ul><ul><li>Commentes </li></ul><ul><li>Functions </li></ul><ul><li>Special symbols </li></ul>
  5. 5. Data type <ul><li>Int 4byte </li></ul><ul><li>Double 8byte </li></ul><ul><li>Float 4byte </li></ul><ul><li>Char 1byte </li></ul><ul><li>Bool 1byte true or false </li></ul>
  6. 6. Functions <ul><li>return_type function_name(args); </li></ul><ul><li>main(){ </li></ul><ul><li>function_name(); </li></ul><ul><li>} </li></ul><ul><li>return_type function_name(args) </li></ul><ul><li>{ </li></ul><ul><li>// </li></ul><ul><li>} </li></ul>
  7. 7. Another way <ul><li>return_type function_name(args) </li></ul><ul><li>{ </li></ul><ul><li>//statements </li></ul><ul><li>} </li></ul><ul><li>main(){ </li></ul><ul><li>function_name(); </li></ul><ul><li>} </li></ul>
  8. 8. Special symbols <ul><li> new line </li></ul><ul><li> backspace </li></ul><ul><li> tab </li></ul><ul><li> start of line </li></ul><ul><li>a Bell sound </li></ul><ul><li>' to print ' </li></ul><ul><li>” to print “ </li></ul><ul><li>? to print ? </li></ul>
  9. 9. Conditions <ul><li>If esle </li></ul><ul><li>Switch case </li></ul>
  10. 10. If else <ul><li>if(condition){ </li></ul><ul><li>//statments </li></ul><ul><li>} </li></ul><ul><li>Else{ </li></ul><ul><li>//statmets </li></ul><ul><li>} </li></ul>
  11. 11. Switch case <ul><li>switch c{ </li></ul><ul><li>case a: </li></ul><ul><li>//statements; </li></ul><ul><li>break; </li></ul><ul><li>case b: </li></ul><ul><li>//statements; </li></ul><ul><li>break; </li></ul><ul><li>default: </li></ul><ul><li>//statements </li></ul><ul><li>break; </li></ul><ul><li>} </li></ul>
  12. 12. Loops <ul><li>For loop </li></ul><ul><li>While </li></ul><ul><li>Do while </li></ul><ul><li>Goto </li></ul><ul><li>Break & continue </li></ul>
  13. 13. For loop <ul><li>Nested for </li></ul><ul><li>for(int i=1;i<10;i++){ </li></ul><ul><li>for(int j=1;j<=i;j++){ </li></ul><ul><li>cout <<j<<” ”; </li></ul><ul><li>} </li></ul><ul><li>cout<<endl; </li></ul><ul><li>} </li></ul><ul><li>1 </li></ul><ul><li>1 2 </li></ul><ul><li>1 2 3 </li></ul><ul><li>1 2 3 4 </li></ul><ul><li>1 2 3 4 5 </li></ul><ul><li>1 2 3 4 5 6 </li></ul><ul><li>1 2 3 4 5 6 7 </li></ul><ul><li>1 2 3 4 5 6 7 8 </li></ul><ul><li>1 2 3 4 5 6 7 8 9 </li></ul>
  14. 14. while <ul><li>while(condition) </li></ul><ul><li>{ </li></ul><ul><li>//statments </li></ul><ul><li>} </li></ul>
  15. 15. Do while <ul><li>{ </li></ul><ul><li>//statmentes </li></ul><ul><li>}dowhile(condition) </li></ul>
  16. 16. GO TO <ul><li>a: //label </li></ul><ul><li>//statments </li></ul><ul><li>if(condition){ </li></ul><ul><li>goto a; </li></ul><ul><li>} </li></ul>
  17. 17. Pointer is very easy <ul><li>int *xadd; </li></ul><ul><li>int x=7; --->(1) </li></ul><ul><li>int y=x; --->(2) </li></ul><ul><li>xadd=&x; -->(3) </li></ul><ul><li>cout<<x<<endl; -->(1) </li></ul><ul><li>cout<<y<<endl; -->(2) </li></ul><ul><li>cout<<xadd<<endl;(3) </li></ul><ul><li>cout<<*xadd<<endl;(3) </li></ul>
  18. 18. <ul><li>Data type *pointer _name; </li></ul><ul><li>pointer _name=&variable name </li></ul><ul><li>Data type &Reference _name=variable name; </li></ul><ul><li>ptr2 = (char*) ptr1; </li></ul><ul><li>converts ptr1 to char pointer before assigning it to ptr2. </li></ul>
  19. 19. Pointer Ex <ul><li>int x=5; </li></ul><ul><li>int y=105; </li></ul><ul><li>int *p1=&x; </li></ul><ul><li>int *p2=&y; </li></ul><ul><li>cout<<&quot; p1=&quot;<<p1<<&quot;p2=&quot;<<p2; </li></ul><ul><li>cout<<&quot; x= &quot;<<x<<&quot;y=&quot;<<y; </li></ul><ul><li>y=x; </li></ul><ul><li>cout<<&quot; p1=&quot;<<p1<<&quot;p2=&quot;<<p2; </li></ul><ul><li>cout<<&quot; x= &quot;<<x<<&quot;y=&quot;<<y; </li></ul><ul><li>x=10; </li></ul><ul><li>*p2=*p1; </li></ul><ul><li>cout<<&quot; p1=&quot;<<p1<<&quot;p2=&quot;<<p2; </li></ul><ul><li>cout<<&quot; x= &quot;<<x<<&quot;y=&quot;<<y; </li></ul><ul><li>Can be =null; </li></ul><ul><li>Can be redeclared </li></ul><ul><li>Deleted by delete </li></ul><ul><li>Delete p1; </li></ul>p1= 0x222 p2=0x223 X=5 y=105 p1= 0x222 p2=0x223 X=105 y=105 p1= 0x222 p2=0x222 X=10 y=10
  20. 20. Reference Ex <ul><li>int x=300; </li></ul><ul><li>int &ref=x; </li></ul><ul><li>cout<<&quot; x= &quot;<<x; </li></ul><ul><li>cout<<&quot; ref= &quot;<<ref; </li></ul><ul><li>ref=600; </li></ul><ul><li>cout<<&quot; x= &quot;<<xx; </li></ul><ul><li>cout<<&quot; ref= &quot;<<ref; </li></ul><ul><li>----------------------- </li></ul><ul><li>x=300 ref=300 </li></ul><ul><li>X=600 ref=600 </li></ul><ul><li>notes </li></ul><ul><li>Can't be=null; </li></ul><ul><li>Can't be redeclared </li></ul><ul><li>----------------------- </li></ul><ul><li>int &Ref= *(new int); </li></ul><ul><li>int x=99; </li></ul><ul><li>&Refr=x; //wrong </li></ul>
  21. 21. Oop <ul><li>Constractor & destractor </li></ul><ul><li>Class </li></ul><ul><li>Header file </li></ul>
  22. 22. Demo
  23. 23. Data structure <ul><li>Array </li></ul><ul><li>Linked list </li></ul>
  24. 24. Array <ul><li>Data type array_name[size]; </li></ul><ul><li>Multidimensional Arrays </li></ul><ul><li>Data type array_name[width,high]; </li></ul>
  25. 25. Linked list <ul><li>Demo </li></ul>
  26. 26. C/C++ under Linux <ul><li>Install on debian family </li></ul><ul><li>sudo apt-get install gcc </li></ul><ul><li>Install on redhat family </li></ul><ul><li>yum -i gcc </li></ul><ul><li>Complie </li></ul><ul><li>gcc filename.cpp -o filename </li></ul><ul><li>Run </li></ul><ul><li>./filename </li></ul>
  27. 27. Make executable file <ul><li>Change the extension of complied file to .sh </li></ul><ul><li>then click on it ,it will run </li></ul>
  28. 28. Create GUI by GTK+ <ul><li>It's work under Linux and windows </li></ul><ul><li>Very beautiful </li></ul><ul><li>Free </li></ul><ul><li>examples </li></ul><ul><li>Gnome </li></ul><ul><li>Gimp </li></ul><ul><li>tutorial1 </li></ul><ul><li>tutorial2 </li></ul><ul><li>For c++ we use gtkmm </li></ul>
  29. 29. C++ and netbeans Demo
  30. 31. References <ul><li>Robert_Lafore-Object_Oriented_Programming_in_C++ </li></ul><ul><li>Data Structures and Algorithm Analysis in C </li></ul><ul><li>http://www.brpreiss.com/books/opus4/html/book.html </li></ul><ul><li>http://cpp.datastructures.net/ </li></ul>
  31. 32. With best wishes Abuouf http://abuouf.wordpress.com [email_address]
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×