Thinking in C++: Volume One: Introduction to Standard C++, Second Edition & Volume Two: Practical Programming C++ C C++ C++ 3 3 C C class C++ C++ C++ C++ string vector 2.1 interpreter compiler 2.1.1 BASIC BASICPython Python Python
39 2.1.2 C linker sep library source-level debugger in-memory compilation RAM 2.1.3 C/C++ preprocessor C++ A+B A + B global optimizer code generator,.o.obj peephole optimizer object Python
40 1 C++ object goal linker librarian 2.1.3.1 type checking static type checking Java dynamic type checking C++ C++ C++ C C++ 2.2 C/C++ C C++ function argument return value C C++ declaration 2.2.1 declaration definition C/C++
41 : C C++ ODR one-definition rule, int x 2.2.1.1 C/C++ func1( ) C/C++ int int C/C++ a func1( ) C/C++ func1( ) a func1( ) 2.2.1.2 C C++C C++ 2.2.1.3 func1( )
42 1 C++ 2.2.1.4 X a a C/C++ extern extern extern func1( ) extern C extern extern
43 C C++ 2.2.1.5 C/C++ header file.h headerfile.h.hxx.hpp #include #include#include C++ include iostream iostream include include 2.2.1.6 C++ include C++ 8 iostream.h C.h C++
44 1 C++ c : C C++.h 2.2.2.o C++ C++ 2.2.3 1) 2) 3) C/C+ 2.2.3.1 C C++
bug C++ 2.2.3.2 C/C++ C/C++ C++ iostream <iostream> 2.2.3.3 C C++ C C C++ C++ C C++ POSIX POSIX UNIX C++ UNIX Linux POSIX DOS/Windows POSIX POSIX 2.3 C++ C++ iostream iostream 2.3.1 iostream iostream iostream cout 45 Perl Python www.perl.org www.python.org
46 1 C++ << C C++ iostream << howdy! cout cout console output 12 2.3.2 1 C C++ namespace C++ using C++ ( standard ) using std using using <iostream>.h, <iostream.h>
47.h using 10 2.3.3 C/C++ main( ) C++ C++ main( ) in C/C++ C++ C/* */C++ C //// /* */ // 2.3.4 Hello, World! <<cout endl C stringc++ string
48 1 C++ character array ASCII 0 \ \n C \t ( ) \\ \b ( ) coutcout << cout /:~ 2 www.bruceeckel.com www.bruceeckel.com 2.3.5 CO2 Hello.cpp GNU C++ Internet 2.4 iostream
49 cast, char ( char ) ASC char(27) escape cout 2.4.1 C character array concatenation C/C++ 2.4.2 cin console input cin cin >>
50 1 C++ 2.4.3 Unix DOS shell C system( ) C/C++ system( ) <cstdlib> system( ) C++ C C C C++ C++ 2.5 C++string C C string string string C++ <string> stringstd using string
s1 s2 s3 s4 string string = string = string string + + string string string += string cout stringstring s1+s2+"!" 2.6 C C++ iostream C <fstream> <fstream> <iostream> cin cout <iostream> ifstream cin ofstreamcout iostream iostream getline( ) string getline( ) ifstream stream string ifstream ofstream while while 51 getline( ) 2 iostreams
52 1 C++ while getline(in,s) true while getline( ) true false while getline( ) getline( ) string string string string 2.7 vector string string string string string string C++ container C++ C++ STL, Standard Template 1994 Library Alex Stepanov San Diego C++ C++ Alex Stepanov
C++ STL C++ SGI ( http://www.sgi.com/technology/stl) STL SGI STL C++ C++ STL C++ SGI STL C++ STL C++ 2 vector vector 2 vector vector C++ vector template Shape vector Cat vector String vector, vector string vector vector<string> stri vectorvector vector vector push_back( ) (. ) push_back( ) put insert( ) 2 push_front( ) ( vector) vector vector C++ push_back( ) vector vector vector indexing n 5 a[4]0 << >> iostreams vector [ ] vector vector vector <vector> 53
54 1 C++ string string vector v whilev whilefor while for while for int i=0 i 0 i vector v size( ) C/C++ i 1i++ i 1 i for i 0 vector 1i cout i cout endl iostreams>>
55 false vector vector<int> vector vector vector vector 2.8 C++ string vector www.bruceeckel.com www.dinkumware.com 2
56 1 C++ C C 3 2.9 Thinking in C++ Annotated Solution Guide http://www.bruceeckel.com 2-1 Hello.cpp 2-2 Stream2.cpp Numconv.cpp * 2-3 2-4 string== 2-5 Fillvector.cpp 2-6 Fillvector.cpp vector 2-7 2-8 vector<float> for 25 vector 2-9 vector<float> 8 for vector vector 2-10 vector<float> 25 vectorvector