Click here to Skip to main content
15,917,709 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: checkbox in List control and image Pin
vicky000001-Jan-09 17:45
vicky000001-Jan-09 17:45 
QuestionAccess Violation 0xC0000005 Pin
whiteclouds31-Dec-08 18:14
whiteclouds31-Dec-08 18:14 
AnswerRe: Access Violation 0xC0000005 Pin
Nibu babu thomas31-Dec-08 23:16
Nibu babu thomas31-Dec-08 23:16 
GeneralRe: Access Violation 0xC0000005 Pin
whiteclouds1-Jan-09 12:46
whiteclouds1-Jan-09 12:46 
Questionprocessor affinity Pin
RomTibi31-Dec-08 13:49
RomTibi31-Dec-08 13:49 
AnswerRe: processor affinity Pin
Mark Salsbery31-Dec-08 15:22
Mark Salsbery31-Dec-08 15:22 
GeneralRe: processor affinity Pin
RomTibi1-Jan-09 2:55
RomTibi1-Jan-09 2:55 
Questionconversion problem Pin
wubousc31-Dec-08 10:17
wubousc31-Dec-08 10:17 
Hi,

Could someone please let me know why my code can not pass compilation? (VC++9.0,vista 64-bit)

The problems happens in the "<<" operator overload function. It seems my code can not pass some constness check.

#include <map>
#include <vector>
#include <iterator>
#include <algorithm>
#include <iostream>

using namespace std;

typedef pair<string,int> pairSI;

struct StringToSIPair
{
explicit StringToSIPair(int val) { intVal = val; }

pairSI operator () (string str)
{
pairSI psi = make_pair(str, intVal);
return psi;
}

int intVal;
};

void VecToMap(vector<string> &vecStr, int iniVal, map<string,int> &siMap)
{
transform(vecStr.begin(), vecStr.end(), inserter(siMap, siMap.begin()), StringToSIPair(iniVal));
}

ostream & operator << (ostream &out, map<string, int> &siMap)
{
for(map<string, int>::iterator it = siMap.begin(); it != siMap.end(); ++it)
{
out<<"key: "<<it->first<<" value: "<<it->second<<endl; // the compiler said there is a conversion problem
}

return out;
}

int main()
{
map<string,int> siMap;
vector<string> strVec;

strVec.push_back("bob");
strVec.push_back("alex");
strVec.push_back("alal");

VecToMap(strVec, 4, siMap);

cout<<siMap<<endl;

return 0;
}

regards,
Bob
AnswerRe: conversion problem Pin
Rick York31-Dec-08 11:47
mveRick York31-Dec-08 11:47 
GeneralRe: conversion problem Pin
wubousc31-Dec-08 13:32
wubousc31-Dec-08 13:32 
QuestionHow to separate a specified number of Bits from a DWORD? Pin
Joseph Marzbani31-Dec-08 8:16
Joseph Marzbani31-Dec-08 8:16 
AnswerRe: How to separate a specified number of Bits from a DWORD? PinPopular
harold aptroot31-Dec-08 8:25
harold aptroot31-Dec-08 8:25 
AnswerRe: How to separate a specified number of Bits from a DWORD? Pin
Jijo.Raj31-Dec-08 11:54
Jijo.Raj31-Dec-08 11:54 
AnswerRe: How to separate a specified number of Bits from a DWORD? Pin
krmed31-Dec-08 14:12
krmed31-Dec-08 14:12 
GeneralRe: How to separate a specified number of Bits from a DWORD? Pin
Richard Andrew x641-Jan-09 6:52
professionalRichard Andrew x641-Jan-09 6:52 
QuestionStuck in ShowWindow Pin
dj440031-Dec-08 4:41
dj440031-Dec-08 4:41 
QuestionRe: Stuck in ShowWindow Pin
Mark Salsbery31-Dec-08 6:13
Mark Salsbery31-Dec-08 6:13 
AnswerRe: Stuck in ShowWindow Pin
led mike31-Dec-08 7:20
led mike31-Dec-08 7:20 
GeneralRe: Stuck in ShowWindow Pin
Mark Salsbery31-Dec-08 7:24
Mark Salsbery31-Dec-08 7:24 
AnswerRe: Stuck in ShowWindow [modified] Pin
dj440031-Dec-08 20:48
dj440031-Dec-08 20:48 
GeneralRe: Stuck in ShowWindow Pin
Mark Salsbery1-Jan-09 6:27
Mark Salsbery1-Jan-09 6:27 
GeneralRe: Stuck in ShowWindow Pin
dj44003-Jan-09 23:06
dj44003-Jan-09 23:06 
Questionhow to solve the following problem? Pin
zhiyuan1631-Dec-08 4:12
zhiyuan1631-Dec-08 4:12 
AnswerRe: how to solve the following problem? Pin
Jijo.Raj31-Dec-08 4:27
Jijo.Raj31-Dec-08 4:27 
QuestionRemoving Command bar controls of Excel-2007 in c++ Pin
SRKSHOME31-Dec-08 1:39
SRKSHOME31-Dec-08 1:39 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.