Click here to Skip to main content
15,914,165 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralHelp Teh N00b Again PLZ Pin
MrNiceBerG24-Feb-04 5:55
MrNiceBerG24-Feb-04 5:55 
GeneralRe: Help Teh N00b Again PLZ Pin
David Crow24-Feb-04 6:07
David Crow24-Feb-04 6:07 
QuestionVSS: how do you organize your projects? Pin
peterchen24-Feb-04 5:46
peterchen24-Feb-04 5:46 
AnswerRe: VSS: how do you organize your projects? Pin
Prakash Nadar24-Feb-04 13:50
Prakash Nadar24-Feb-04 13:50 
GeneralBug in WideCharToMultiByte Pin
Anonymous24-Feb-04 5:02
Anonymous24-Feb-04 5:02 
GeneralRe: Bug in WideCharToMultiByte Pin
Prakash Nadar24-Feb-04 5:24
Prakash Nadar24-Feb-04 5:24 
GeneralRe: Bug in WideCharToMultiByte Pin
Anonymous24-Feb-04 18:35
Anonymous24-Feb-04 18:35 
Generalc2678 issue Pin
pwyzorski24-Feb-04 4:55
pwyzorski24-Feb-04 4:55 
Hey,

I'm trying to get some code here to compile and I'm having an issue. The "GetMinVal" method below should be defined as returning a const since it doesn't modify the underlying class. I also eventually need to access it from a
friend std::ostream& operator << (std::ostream&, const WT300_QaStateTable&);
method which will need for it to be a const.

My question is how do I make the following compiler error go away and still maintain "GetMinVal" as a const method.

Gotten using VC++ 2003, ver 7.1...
...\c2678_err.cpp(17): error C2678: binary '[' : no operator found which takes a left-hand operand of type 'const MAP_STR_STR' (or there is no acceptable conversion)

<br />
#include "StdAfx.h"<br />
<br />
#include <map><br />
#include <string><br />
<br />
using namespace std;<br />
<br />
typedef map<std::string, std::string> MAP_STR_STR;<br />
<br />
class c2678_err<br />
{<br />
public:<br />
	c2678_err(void);<br />
	~c2678_err(void);<br />
<br />
	void SetMinVal(std::string key, std::string val) {mMinVal[key] = val;}<br />
	std::string GetMinVal(std::string key) const {return mMinVal[key];} //line 17<br />
<br />
private:<br />
<br />
	MAP_STR_STR mMinVal;<br />
};<br />
<br />
c2678_err::c2678_err(void)<br />
{<br />
}<br />
<br />
c2678_err::~c2678_err(void)<br />
{<br />
}<br />
<br />
main()<br />
{<br />
	c2678_err myProblem;<br />
	std::string howMany;<br />
<br />
	myProblem.SetMinVal("dogs", "02");<br />
	howMany = myProblem.GetMinVal("dogs");<br />
<br />
	cout << howMany;<br />
}


regards,
~Patrick
GeneralRe: c2678 issue Pin
Jonas Larsson24-Feb-04 6:11
Jonas Larsson24-Feb-04 6:11 
GeneralRe: c2678 issue Pin
Jonas Larsson24-Feb-04 6:12
Jonas Larsson24-Feb-04 6:12 
GeneralRe: c2678 issue Pin
pwyzorski24-Feb-04 6:46
pwyzorski24-Feb-04 6:46 
QuestionHow to know whether or not Internet Connection Firewall is enabled or not for a network connection. Pin
koteswara24-Feb-04 4:53
koteswara24-Feb-04 4:53 
GeneralWSDL problem... Pin
Orkun GEDiK24-Feb-04 4:50
Orkun GEDiK24-Feb-04 4:50 
GeneralRe: WSDL problem... Pin
Prakash Nadar24-Feb-04 4:55
Prakash Nadar24-Feb-04 4:55 
GeneralRe: WSDL problem... Pin
Orkun GEDiK24-Feb-04 4:58
Orkun GEDiK24-Feb-04 4:58 
GeneralwRITE 2 a textfile Pin
wytse24-Feb-04 4:13
wytse24-Feb-04 4:13 
GeneralRe: wRITE 2 a textfile Pin
toxcct24-Feb-04 4:23
toxcct24-Feb-04 4:23 
GeneralRe: wRITE 2 a textfile Pin
Anonymous24-Feb-04 4:58
Anonymous24-Feb-04 4:58 
GeneralRe: wRITE 2 a textfile Pin
wytse24-Feb-04 5:43
wytse24-Feb-04 5:43 
GeneralRe: wRITE 2 a textfile Pin
Robert A. T. Káldy24-Feb-04 20:57
Robert A. T. Káldy24-Feb-04 20:57 
GeneralHook problem Pin
Silly Boy24-Feb-04 2:50
Silly Boy24-Feb-04 2:50 
GeneralRe: Hook problem Pin
David Crow24-Feb-04 9:33
David Crow24-Feb-04 9:33 
GeneralPreCreateWindow Pin
Jnewg524-Feb-04 2:48
Jnewg524-Feb-04 2:48 
GeneralRe: PreCreateWindow Pin
Prakash Nadar24-Feb-04 2:53
Prakash Nadar24-Feb-04 2:53 
Questionhow to read Viedio CD sectors Pin
longdafeng24-Feb-04 2:37
longdafeng24-Feb-04 2:37 

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.