Software Development with C++ - CiteSeerX

29 downloads 471 Views 808KB Size Report
36 Extractor and inserter for class Student . ..... panies that use C++ include (see also the course web page): Adobe pr
Software Development with C++ Lecture Notes

Peter Grogono

These notes may be copied for students who are taking either of these courses: COMP 6441 Advanced Programming Practices COMP 446 Designing Programs with C++.

© Peter Grogono, 2005 Department of Computer Science and Software Engineering Concordia University, Montreal, Quebec

CONTENTS

ii

Contents 1 Getting Started

1

1.1 Hello, world! . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

1

1.2 Compiling C++ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

5

1.2.1 The compilation process . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

5

1.2.2 Compiling with Visual C++ .NET . . . . . . . . . . . . . . . . . . . . . . . . . .

7

1.2.3 Compiling with gcc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

8

1.3 Hello, world! — The Details . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

8

1.4 Namespaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

10

1.5 Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

12

1.6 A Pretty Frame . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

14

2 Testing and Looping

17

2.1 Conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

17

2.2 Conditional Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

19

2.3 Loops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

19

2.4 Example: Computing the Frame

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

21

2.5 Counting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

24

2.6 Loop Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

25

2.6.1 Counting Lines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

26

2.6.2 Finding Roots by Bisection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

28

2.6.3 Maximum Subsequence

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

29

2.7 Assertions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

32

2.8 Oh Notation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

34

3 Batches of "111886:6:??AAF "FHHMMOO55557799@@>>>BBBGGIIKK"[b]-64;C="C@=::C@@==@=:C@=:C@=:C5""31/513/5131/ "31/531/53"[b ]-64;S=bx?(X^=Y):0, I (x,Y/2, )):(E=X); }H(x){I(x, _,0);}p;q( c,x,y,z,k,l,m,a, b){F( );x-=E*M ;y-=S*M ;z-=C*M ;b=x* x/M+ y*y/M+ p=((b=a*a/M -y*l/M-z *m/M; *z/M-D*D *M;a=-x *k/M b)>=0?(I (b*M,_ ,0),b =E, a+(a>b ?-b:b)): -1.0);}Z;W; (c,x,y, z,k,l, m,a){Z=! c? -1:Z;c 0&&c!= a&& (p=0? (e+=h*W/M,f+=i*W/M,g+=j*W/M,F(Z),u=e-E*M,v=f-S*M,w=g-C*M,b=(-2*u-2*v+w /3,H(u*u+v*v+w*w),b/=D,b*=b,b*=200,b/=(M*M),V=Z,E!=0?(u=-u*M/E,v=-v*M/E,w=-w*M E):0,E=(h*u+i*v+j*w)/M,h-=u*E/(M/2),i-=v*E/(M/2),j-=w*E/(M/2),n(e,f,g,h,i,j,d,Z,0,0),Q/=2,T/=2, U/=2,V=V

Suggest Documents