Notes
Slide Show
Outline
1
 
2
 
3
 
4
 
5
 
6
 
7
 
8
 
9
 
10
 
11
 
12
 
13
 
14
 
15
 
16
 
17
 
18
 
19
 
20
BikeStore Output
  • Bike Store created...
  • Bike store size is 0
  • Bike store capacity is 10
  • Adding bikes to the store
  • Bike added successfully true
  • Bike added successfully true
  • Bike store size is 2
  • Bike store capacity is 10
  • Outputting Bike Store:
  • …
  • Adding 10 bikes to the store
  • Resize...
  • Bike store size is 12
  • Bike store capacity is 20
  • Removing 10 bikes from the store
  • Shrinking...
  • Shrinking...
  • Shrinking...
  • Bike store size is 2
  • Bike store capacity is 2


21
 
22
BadPointerCopy.cpp
  • What happened?
  • BikeStore laStore;
  • BikeStore ocStore;


  • Bike truth("Ellsworth Truth", 17, 26.0);
  • Bike id("Ellsworth Id", 19, 26.0);


  • laStore.addBike(truth);
  • laStore.addBike(id);


  • ocStore = laStore;


  • ocStore.removeBike(truth);
  • cout << "Orange County Store\n";
  • outputSizeAndCapacity(ocStore);
  • cout << ocStore;
  • // Shrink() killed laStores pointer
23
 
24
 
25
 
26
 
27
 
28
 
29
 
30
 
31
 
32
 
33
 
34
 
35
 
36