C++ Programming How To.pdf

(212 KB) Pobierz
C++ Programming HOW-TO
C++ Programming HOW−TO
C++ Programming HOW−TO
Table of Contents
C++ Programming HOW−TO. ..........................................................................................................................1
Al Dev (Alavoor Vasudevan) alavoor@yahoo.com. ..............................................................................1
1. Introduction. .........................................................................................................................................1
2. String Class Varieties.. ........................................................................................................................1
3. Download String . ................................................................................................................................1
4. Usage of String class. ...........................................................................................................................1
5. String.h file. .........................................................................................................................................1
6. Renaming the String class. ...................................................................................................................1
7. File Class. .............................................................................................................................................2
8. C++ Zap (Delete) function.. ................................................................................................................2
9. Pointers are problems. .........................................................................................................................2
10. Usage of my_malloc and my_free . ...................................................................................................2
11. Debug files. ........................................................................................................................................2
12. Java like API. .....................................................................................................................................2
13. IDE tools for C++ . ............................................................................................................................2
14. C++ Online Textbooks and Docs.. ....................................................................................................2
15. C++ Coding Standards. ......................................................................................................................2
16. C++ Online Docs. ..............................................................................................................................2
17. Memory Tools. ...................................................................................................................................2
18. Related URLs. ....................................................................................................................................2
19. C++ Scripting Languages. .................................................................................................................2
20. Templates. ..........................................................................................................................................2
21. STL References. ................................................................................................................................2
22. Threads in C++. .................................................................................................................................3
23. C++ Utilities ......................................................................................................................................3
24. Other Formats of this Documen.. ......................................................................................................3
25. Copyright. ..........................................................................................................................................3
26. Appendix A String Program Files . ...................................................................................................3
1. Introduction. .........................................................................................................................................3
1.1 C++ v/s Java. ......................................................................................................................................3
1.2 Which one Ada95, "C", "C++" or Java ??. ........................................................................................4
1.3 Problems facing the current C++ compilers. .....................................................................................5
1.4 COOP − C++ Object Oriented Programming−language. ..................................................................6
2. String Class Varieties. ........................................................................................................................7
2.1 Multiple Inheritance − Sample Custom String class . .......................................................................7
3. Download String . ...............................................................................................................................8
4. Usage of String class. ...........................................................................................................................8
4.1 Operators. ...........................................................................................................................................9
4.2 Functions. ...........................................................................................................................................9
5. String.h file. .......................................................................................................................................10
6. Renaming the String class. .................................................................................................................18
6.1 Case 1: Simple rename. ....................................................................................................................18
6.2 Case 2: Resolve conflic.. .................................................................................................................18
7. File Class. ...........................................................................................................................................19
8. C++ Zap (Delete) function. ..............................................................................................................19
9. Pointers are problems. ......................................................................................................................20
10. Usage of my_malloc and my_free . ................................................................................................21
10.1 Garbage Collector for C++ . .........................................................................................................22
i
15213562.001.png
C++ Programming HOW−TO
Table of Contents
11. Debug files. ......................................................................................................................................23
12. Java like API. ...................................................................................................................................23
13. IDE tools for C++ . .........................................................................................................................23
14. C++ Online Textbooks and Docs.. .................................................................................................24
15. C++ Coding Standards. ....................................................................................................................24
16. C++ Online Docs. ............................................................................................................................26
16.1 C++ Tutorials. ................................................................................................................................26
16.2 Useful links. ...................................................................................................................................27
16.3 C++ Quick−Reference. ..................................................................................................................27
16.4 C++ Usenet Newsgroups. ..............................................................................................................27
17. Memory Tools. .................................................................................................................................27
18. Related URLs. ..................................................................................................................................27
19. C++ Scripting Languages. ...............................................................................................................28
19.1 PIKE (C/C++ Scripting Language.. ..............................................................................................28
19.2 PHP (C++ Scripting Language). ....................................................................................................28
20. Templates. ........................................................................................................................................28
21. STL References. .............................................................................................................................29
21.1 Overview of the STL . ...................................................................................................................30
21.2 Header Files. ..................................................................................................................................31
21.3 The Container Classes Interface . ..................................................................................................31
21.4 Vectors . .........................................................................................................................................32
Constructing Vectors . ..............................................................................................................32
Checking Up on Your Vector . .................................................................................................33
Accessing Elements of a Vector . .............................................................................................34
Inserting and Erasing Vector Elements ...................................................................................35
Vector Iterators . .......................................................................................................................36
Comparing Vectors . .................................................................................................................37
21.5 Iterators and the STL. ....................................................................................................................38
21.6 Lists. ...............................................................................................................................................38
21.7 Sets. ...............................................................................................................................................38
Constructing Sets. .....................................................................................................................38
What are Function Objects?. .....................................................................................................40
A Printing Utility. .....................................................................................................................42
How Many Elements?. ..............................................................................................................43
Checking the Equality of Sets. .................................................................................................43
Adding and Deleting Elements. ................................................................................................44
Finding Elements. .....................................................................................................................45
Set Theoretic Operations. .........................................................................................................46
21.8 Maps. ..............................................................................................................................................48
21.9 STL Algorithms. ............................................................................................................................49
22. Threads in C++. ...............................................................................................................................49
22.1 Threads Tutoria. ............................................................................................................................49
22.2 Designing a Thread Class in C++. .................................................................................................49
Introduction. ..............................................................................................................................50
Brief Introduction To Threads. .................................................................................................50
Basic Approach. ........................................................................................................................50
The Implementation. .................................................................................................................50
Using The Thread Class. ...........................................................................................................52
ii
15213562.002.png
C++ Programming HOW−TO
Table of Contents
Conclusion. ...............................................................................................................................52
23. C++ Utilities ....................................................................................................................................52
24. Other Formats of this Documen.. ....................................................................................................53
25. Copyright. ........................................................................................................................................54
26. Appendix A String Program Files . ................................................................................................55
iii
15213562.003.png
C++ Programming HOW−TO
Al Dev (Alavoor Vasudevan) alavoor@yahoo.com
v37.0, 27 April 2001
This document provides a comprehensive list of C++ URL pointers, links to C++ online textbooks, and
programming tips on C++. This document also provides a C++ library which imitates Java−language, and
which has various methods to avoid memory problems in C++. Using this library you can compile Java's
source code under C++. This document serves as a "Home of C++ language". The information given here
will help you to program properly in C++ language and applies to all the operating systems that is − Linux,
MS DOS, BeOS, Apple Macintosh OS, Microsoft Windows 95/98/NT/2000, OS/2, IBM OSes (MVS, AS/400
etc..), VAX VMS, Novell Netware, all flavors of Unix like Solaris, HPUX, AIX, SCO, Sinix, BSD, etc.. and to
all other operating systems which support "C++" compiler (it means almost all the operating systems on this
planet).
·
·
·
·
C++ Programming HOW−TO
1
15213562.004.png
Zgłoś jeśli naruszono regulamin