Transcription of An Introduction to C++
1 An Introductionto C++AbstractThe aim of the notes is to provide an Introduction to the C++ programming :Ian D :November 2006 Ian D to copy all or part of this work is granted, provided that thecopies are not made or distributed for resale (except a nominal copy fee may be charged),and provided that the Author, Copyright, & No Warranty sections are retained verbatim andare displayed conspicuously. If anyone needs other permissions that aren t covered by theabove, please contact the Warranty:This work is provided on an as is basis. The author provides no warrantywhatsoever, either express or implied, regarding the work, including warranties with respectto its merchantability or fitness for any particular comments notes are dedicated to the people who have implemented the gcc suite of software, toDinkumware and to and g++The gcc home page is following comments are taken from their home , the GNU Compiler Collection, includes front ends for C, C++, Objective-C, Fortran,Java, and Ada, as well as libraries for these languages (libstdc++, libgcj.)
2 We strive to provide regular, high quality releases, which we want to work well on a vari-ety of native and cross targets (including GNU/Linux), and encourage everyone to contrib-ute changes and help testing GCC. Our sources are readily and freely available via CVSand weekly decisions about GCC are made by the steering committee, guided by the steering committee membersThe steering committee consists of the following members. The best place to reach them isthe gcc Bothner, Joe Buck (Synopsys), David Edelsohn (IBM), Kaveh R. Ghazi, JeffreyA. Law (Red Hat), Marc Lehmann (Technische Universit t Karlsruhe), Jason Merrill(Red Hat), David Miller (Red Hat), Mark Mitchell (CodeSourcery), Toon Moene(Koninklijk Nederlands Meteorologisch Instituut), Gerald Pfeifer (SUSE), JoelSherrill (OAR Corporation), Jim Wilson (Specifix Inc)Membership in the steering committee is a personal membership.
3 Affiliations are listed foridentification purposes only; steering committee members do not represent their employersor academic Dinkumware home page is provide the only standard C++ library at this 've all done a great job!Table of Contents1 Overview .. resources .. material .. and and low cost compilers .. of the and .. Details ..222 An Introduction to Programming Languages and Object Oriented Pro-gramming .. 66, 1966 .. , 1975, ANSI & BSI 1982, ISO 1983, Extended Pascal 1991? .. 77, 1978 .. , K&R 1978, Standard 1989.. 2, 1982, Standard 1996? .. , ISO 8652: 1987 .. ++, 1986, Standard November 1997 .. 2, Late 1980 s, early 1990 s.. 90, 1991.. , 1988 .. , ISO 8652: 1995 .. Compilation .. Compilation .. Data Types .. Data Types .. and General .. and References.
4 Variables .. Binding .. Handling .. Important Milestones in Program Language Development .. Programming .. Refinement .. Structuring, Concrete vs Abstract Data Hiding Modules .. of Object Oriented Fortran Fortran 95, Fortran 2003, Fortran 2006 and Coarray Fortran .. C++.. Oriented Programming .. Oriented Languages .. 1967 .. 1978 .. ++ .. 2 .. 95 .. 90 .. OO Approach .. s Approach .. et al .. Steps .. Developments .. Environments .. Development Tools .. Components .. , OLE, ..443 Introduction to Operating Systems .. of operating 1940s .. 1950s .. 1960s .. 1960s and 1970s .. 1970s, 1980s and ..474 Introduction to Using a Computer user systems .. useful things to know .. Methods of Using Computer Systems to Develop Fortran 's Specific Information.
5 Exceed and ssh accessing the central King's Unix accessing the King's Unix system .. Installed Software - cygwin and g++ ..525 Introduction to Problem Solving .. language .. refinement .. programming .. oriented programming .. analysis and design .. definition .. study and fact finding .. design .. and testing ..596 An Introduction to C++ .. of a programming language .. description structures .. processing statements .. and output (I/O) statements .. World New standard C++ style .. World Old C style .. text i/o using C style arrays of char .. name, type and value .. text i/o using C++ style strings .. numeric i/o .. C++ Rules and Terminology .. Programming ++ for C .. and C style strings .. ++ Character Set .. structure of a C++ program ..717 Arithmetic and Expressions in C++.
6 Numeric types .. Numeric Type .. on a theme - signed, Numeric Type .. Type Conversion Rules .. , precision and size of numbers .. numbers getting too big.. numbers getting too small .. Data as a form of Integer and Expression Evaluation .. Evaluation .. and , Precedence and :: [scope resolution] class_name :: member .. :: [global] :: name .. [member selection] .. > [member selection] pointer -> member .. [] [subscripting] pointer [expr] .. () [function call] expr (expr_list).. () [value construction] type(expr_list).. ++ [post increment] lvalue ++.. [post decrement] lvalue .. [size of object] sizeof expr .. [size of type] sizeof (type) .. ++ [pre increment] ++ lvalue .. [pre decrement] ~ [complement] ~ expr .. ! [not] ! expr .. [unary minus] - + [unary plus] + [address of] & * [dereference] * [create] new [destroy] delete pointer.
7 [] [destroy array] delete [] pointer .. () [cast] (type) expr .. * [member selection] object.* >* [member selection] pointer -> * pointer_to_member .. * [multiply] expr * expr .. [divide] expr / expt .. [modulo or remainder] expr % expr .. + [plus] expr + [minus] expr - << [shift left] expr << expr .. >> [shift right] expr >> expr .. < [less than] expr < expr .. <= [less than or equal] expr <= expr .. > [greater than] expr > expr .. >= [greater than or equal] expr >= expr .. [equal] expr == expr .. != [not equal] expr != expr .. [bitwise AND] expr & expr .. ^ [bitwise exclusive OR] expr ^ | [bitwise inclusive OR] expr | expr .. [logical AND] expr && || [logical inclusive OR] expr || expr .. : [conditional expression] expr ? expr : expr .. [conventional assignment] lvalue = expr.
8 *= [multiply and assign] lvalue *= expr .. [divide and assign] lvalue /= expr .. [modulo and assign] lvalue %= += [add and assign] lvalue += expr .. [subtract and assign] lvalue -= expr .. <<= [shift left and assign] lvalue <<= expr .. >>= [shift right and assign] lvalue >>= [AND and assign] lvalue &= |= [inclusive OR and assign] lvalue |= expr .. ^= [exclusive OR and assign] lvalue ^= expr .. [throw exception] throw , [comma] expr , expr .. Data Types .. supported via <complex> .. Data as Numeric Data .. use the const attribute .. 45 but effectively 57 with variants .. the order of expression evaluation is often main() ..948 Strings and other Data Types .. Data or Strings .. Style strings .. 1 .. 2 .. 3 .. (s1,s2) .. (s1,s2) .. (s1,s2) .. (s).. (s,c).. ++ Style strings <string>.
9 3 .. for use .. or Logical Data .. Conversion .. and C++ .. of characters as an array of char .. of characters as a or boolean .. Variable .. Types ..1059 Arrays, Vectors and Valarrays in C++ .. C Style arrays .. d example hard coded size .. d array parameterised d Array latitude and longitude .. physics voltage Zone Example .. d array d initialisation .. Array Manipulation .. example using vectors .. checking .. checking with try/catch .. array assignment .. example using valarray .. Element Ordering in C++ .. , Vector and Valarray Data Types .. control structure for loop ..11910 Control Statement or Block .. (expression) statement .. (expression) statement; else statement; .. (expression) statement .. (expression) statement.
10 Statement while (expression);.. (init-statement;expression 1; expression 2) statement .. break, continue, goto statements .. Key expressions .. and relational operators .. block of statements { .;.;.} .. Statements .. if expression statement .. if expression statement else statement .. switch expression statement .. statement while for () statement .. statement .. statement .. statement .. Problems .. Bibliography ..13311 Pointers .. 1: Basic Pointer 2: Arrays and Pointers .. 3: Pointers and 4: Indiscriminate Pointer .. * pointer to .. address of .. and pointers ..13912 Functions .. Functions .. function usage .. arguments of numeric type to standard maths functions .. in <cmath>.. Defined d array as argument and one function, vector as argument.