AP Computer Science Workshop


AP Classes: apvector

 
Code Effect
apvector<char> a; constructs a 0 element vector of char
apvector<int> a(10), b (20); constructs a 10 element vector of int, indexed 0 to 9
apvector<double> d(5, 0.0); constructs a 5 element vector of double, initialized to 0.0
 
b = a; assignment works for apvectors (even of different sized vectors)
b.length(); returns vector's current size (10)
 
d[0] = 7.5; looks like an array
cout << d[2] << endl; ditto
 
a.resize(50); expandable arrays???     Indeed.

Previous slide Mark Stehlik, Carnegie Mellon University Next slide