-
November 5th, 2002, 12:02 PM
#1
Let's see if this works
Code:
#include "stdafx.h"
#include <map>
#include <string>
#include <iostream>
using namespace std;
// Using a string object for both the key
// and the item
#pragma warning ( disable : 4786 )
typedef multimap<string, string> NameList;
typedef NameList::iterator NameIt;
int main()
{
NameList Names;
NameIt CurrentName;
// An example of adding one element
// to the map:
string NameA1 = "Patty Anderson";
string NameA2 = "Anderson";
Names.insert
(NameList::value_type(NameA2, NameA1));
// This is the code I am trying to use to
// output the list to the console:
/*
for( CurrentName = Names.begin(); CurrentName != Names.end(); CurrentName++);
{
// Program crashes here.
cout << static_cast<string>(CurrentName->second) << endl;
}
*/
CurrentName = Names.begin();
while( CurrentName != Names.end() )
{
cout << (*CurrentName).second;
cout << endl;
++CurrentName;
}
for( CurrentName = Names.begin(); CurrentName != Names.end(); CurrentName++ )
{
cout << (*CurrentName).second <<endl;
cout << endl;
}
return 0;
}
Martin Breton
3D vision software developer and system integrator.
-
November 5th, 2002, 12:06 PM
#2
Code:
CFiddleDi::Prociekt()
Martin Breton
3D vision software developer and system integrator.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|