Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions ch09/ex9_38.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@
//

#include <iostream>
#include <string>
#include <vector>

int main()
{
std::vector<std::string> v;
for (std::string buffer; std::cin >> buffer; v.push_back(buffer))
std::cout << v.capacity() << std::endl;

std::vector<int> ivec;
auto prev = ivec.capacity();
for (int i = 0; i < 128; ++i)
{
ivec.push_back(i);
if(prev != ivec.capacity())
cout << prev << "-> " << (prev = ivec.capacity()) << endl;
}
return 0;
}
2 changes: 2 additions & 0 deletions ch13/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ Yes, it does. Because, as described, the newly defined copy constructor can hand
>What if the parameter in f were const numbered&? Does that change the output? If so, why? What output gets generated?

Yes, the output will change. Because no copy operation happens within function `f`. Thus, the three Output are the same.
//NO!!!,they are not same.


## Exercise 13.17
> Write versions of numbered and f corresponding to the previous three exercises and check whether you correctly predicted the output.
Expand Down