- struct Student
- {
- string name;
- int height; // height in inches
- double weight; // weight in pounds
- string dob; // date of birth mm/dd/yy
- }
- tvector<int> num(6);
- +--+--+--+--+--+--+
- | ?| ?| ?| ?| ?| ?|
- +--+--+--+--+--+--+
- --0--1--2--3--4--5-
-
- num[1] = 21; num[5] = 13;
- +--+--+--+--+--+--+
- | ?|21| ?| ?| ?|13|
- +--+--+--+--+--+--+
- --0--1--2--3--4--5-
-
- int k;
- for (k=2; k<6; k++) num[k] = k*k;
- +--+--+--+--+--+--+
- | ?|21| 4| 9|16|25|
- +--+--+--+--+--+--+
-
- int j;
- for (j=0; j<6; j++) cout << num[j] << " ";
-
- ? 21 4 9 16 25
- tvector<type> name;
- tvector<type> name(expression);
- tvector<type> name(expression, value);
tvector<int> nums(4, -1);
tvector<string> words(12, "Hi");
for(k = 0; k < 4; k++)
nums[k] = -1;
for(k = 0; k < 12; k++)
words[k] = "Hi";
.resize(int size)
member function
.capacity()
member function
context3.cpp