Skip to content

Commit

Permalink
Update ex13_48.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
Mooophy committed Jun 28, 2015
1 parent c0b6875 commit 8aacc48
Showing 1 changed file with 28 additions and 28 deletions.
56 changes: 28 additions & 28 deletions ch13/ex13_48.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,39 +16,39 @@ void bar(const String& x)

String baz()
{
String ret("world");
return ret;
String ret("world");
return ret;
}

int main()
{
char text[] = "world";

String s0;
String s1("hello");
String s2(s0);
String s3 = s1;
String s4(text);
s2 = s1;

foo(s1);
bar(s1);
foo("temporary");
bar("temporary");
String s5 = baz();

std::vector<String> svec;
char text[] = "world";

String s0;
String s1("hello");
String s2(s0);
String s3 = s1;
String s4(text);
s2 = s1;

foo(s1);
bar(s1);
foo("temporary");
bar("temporary");
String s5 = baz();

std::vector<String> svec;
svec.reserve(8);
svec.push_back(s0);
svec.push_back(s1);
svec.push_back(s2);
svec.push_back(s3);
svec.push_back(s4);
svec.push_back(s0);
svec.push_back(s1);
svec.push_back(s2);
svec.push_back(s3);
svec.push_back(s4);
svec.push_back(s5);
svec.push_back(baz());
svec.push_back("good job");
svec.push_back(baz());
svec.push_back("good job");

for (const auto &s : svec) {
std::cout << s.c_str() << std::endl;
}
for (const auto &s : svec) {
std::cout << s.c_str() << std::endl;
}
}

0 comments on commit 8aacc48

Please sign in to comment.