This topic has been archived. It cannot be replied.
-
工作学习 / IT技术讨论 / make the C++ code compiled
-bluelotus(时光漫步);
2003-6-18
{1405}
(#1247483@0)
-
Try this out, be sure to use g++ instead of gcc, because gcc can't link some stl lib. also don't try to use: char* s = "abc"; A foo(string(s));
that's not standard C++ style#include <string>
using std::string;
#include <map>
using std::map;
class A {
public:
A(const string &s) : _s(s) { }
bool operator<(const A& a) const { return _s < a._s; }
//
string _s;
};
int main()
{
map<A, int> m;
string s = "abc";
A foo(s);
map<A, int>::iterator iter = m.find(foo);
}
-zhao_e(zhao_e);
2003-6-18
{316}
(#1247924@0)