这是今天写程序中遇到的两个诡异的问题。我的
IDE 是
VC++2005 ExpressiEdition 。
第一个问题是关于 map 的。话不多说,以下 20 多行的 C++ 代码重现了我遇到的问题:
#include <iostream>
#include <map>
using namespace std;
struct S {
int x, y;
S(int xx, int yy): x(xx), y(yy) {}
bool operator<(const S& s) const {
return x < s.x && y < s.y;
}
};
map<S, int> ms;
int main() {
ms.insert(map<S, int>::value_type(S(31, 41), 59));
S test(31, 59);
if(ms.find(test) != ms.end()) {
cout << "Find the value: " << ms[test] << endl;
} else {
cout << "Find Failure/n";
}
return 0;
}
使用 VC++6.0 , VC++2005 Express Edition, VC++2005 command line compiler( 不
第一个问题是关于 map 的。话不多说,以下 20 多行的 C++ 代码重现了我遇到的问题:
#include <iostream>
#include <map>
using namespace std;
struct S {
int x, y;
S(int xx, int yy): x(xx), y(yy) {}
bool operator<(const S& s) const {
return x < s.x && y < s.y;
}
};
map<S, int> ms;
int main() {
ms.insert(map<S, int>::value_type(S(31, 41), 59));
S test(31, 59);
if(ms.find(test) != ms.end()) {
cout << "Find the value: " << ms[test] << endl;
} else {
cout << "Find Failure/n";
}
return 0;
}
使用 VC++6.0 , VC++2005 Express Edition, VC++2005 command line compiler( 不