I have been suspecting "C Primer Answer Book" this book is too eager to publish. For Exercise 6.7, I wrote a Test program: #include #include #include using namespace std; int main () {vector svec; svec.reserve (1024); int N COUT << "please input n:"; cin >> n; do {if (n == 0) Return 0; for (int i = 0; i > n);} result of execution on gnu c compiler follows: please input n: 256 after resize 384 max size 1073741823capacity size 1024 please input n: 512 after resize 768 max size 1073741823capacity size 1024 please input n: 1000 after resize 1500 max size 1073741823capacity size 2000 please input n: 1048 after resize 1572 max size 1073741823capacity size 2000 please input n: 0 // execution result Exitvc2003 compiler follows: please input n: 256 after resize 384 max size 153391689capacity siz e 1024
please input n: 512 after resize 768 max size 153391689capacity size 1066 please input n: 1000 after resize 1500 max size 153391689capacity size 1599 please input n: 1048 after resize 1572 max size 153391689capacity size 1599 please input n: 0 // exit Conclusion: This There is no exact answer to the topic, if you have a definitive answer, then it is definitely wrong!