CS ¡162 ¡ Intro ¡to ¡Programming ¡II ¡
Big ¡3 ¡
1 ¡
CS 162 Intro to Programming II Big 3 1 Nota4on - - PowerPoint PPT Presentation
CS 162 Intro to Programming II Big 3 1 Nota4on The -> operator is used on pointers: Student *s1 = new Student(Bob);
1 ¡
2 ¡
3 ¡
¡
¡
4 ¡
5 ¡
6 ¡
¡
7 ¡
8 ¡
9 ¡
ia1:array ¡ ia2:array ¡
¡ ia1:array ¡ ia2:array ¡
10 ¡
10 ¡ 10 ¡ 10 ¡ 10 ¡ 10 ¡ 10 ¡ 10 ¡ 10 ¡ 10 ¡ 10 ¡ 10 ¡ 10 ¡ 10 ¡ 10 ¡ 10 ¡
Why? ¡
11 ¡
12 ¡
IntArray& ¡IntArray::operator=(const ¡IntArray& ¡rightSide) ¡{ ¡ if( ¡this ¡== ¡&rightSide ¡) ¡{ ¡ return ¡*this; ¡ } ¡else ¡{ ¡ if( ¡array ¡!= ¡NULL ¡) ¡ delete ¡[] ¡array; ¡ array ¡= ¡new ¡int[rightSide.size]; ¡ size ¡= ¡rightSide.size; ¡ for( ¡int ¡i ¡= ¡0; ¡i ¡< ¡size; ¡i++ ¡) ¡{ ¡ array[i] ¡= ¡rightSide.array[i]; ¡ } ¡ return ¡*this; ¡ } ¡ } ¡
13 ¡
14 ¡
15 ¡
16 ¡
17 ¡