Skip to content

Commit

Permalink
Update ex14_16_StringMain.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
Mooophy committed Jun 28, 2015
1 parent e704183 commit 5de3bfa
Showing 1 changed file with 39 additions and 39 deletions.
78 changes: 39 additions & 39 deletions ch14/ex14_16_StringMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,55 +7,55 @@

void foo(String x)
{
std::cout << x << std::endl;
std::cout << x << std::endl;
}

void bar(const String& x)
{
std::cout << x.c_str() << std::endl;
std::cout << x.c_str() << std::endl;
}

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

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

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

if (s2 == s1)
std::cout << "s2 == s1" << std::endl;

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

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

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

std::cout << "Input a string: ";
String s6;
std::cin >> s6;
std::cout << s6 << std::endl;
char text[] = "world";

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

if (s2 == s1)
std::cout << "s2 == s1" << std::endl;

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

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

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

std::cout << "Input a string: ";
String s6;
std::cin >> s6;
std::cout << s6 << std::endl;
}

0 comments on commit 5de3bfa

Please sign in to comment.