Skip to content

Commit

Permalink
fixed #227
Browse files Browse the repository at this point in the history
  • Loading branch information
Mooophy committed Apr 29, 2015
1 parent 01ede61 commit 3c41aa2
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions ch10/ex10_05.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,11 @@
// Copyright (c) 2014 pezy. All rights reserved.
//
// @Brief In the call to equal on rosters, what would happen if both rosters held C-style strings, rather than library strings?
// @Answer It's the same as `std::string`
// @Answer For such case, std::equal is going to compare the address value rather than the string value.
// So the result is not the same as std::string. Try to avoid coding this way.
// Check #227 for more detail.
//

#include <algorithm>
#include <iostream>
#include <vector>
#include <list>
int main(){}

int main()
{
std::vector<const char *> roster1{"Mooophy", "pezy", "Queequeg"};
std::list<const char *> roster2{"Mooophy", "pezy", "Queequeg", "shbling", "evan617"};
std::cout << std::equal(roster1.cbegin(), roster1.cend(), roster2.cbegin());
}

// out
// 1

0 comments on commit 3c41aa2

Please # to comment.