I am having a problem with the code that inserts an item into a map. I think it is really a decleration problem. I use typedef the set it up because the map is used in two classes.
I cannot cut and paste from my work computer for various reasons so please comment on any typos, but presumed I made an entry error. There is only one compiile error in the program and that is on the line marked as such.
Then from the .cpp file I try to insert a name into the map.
The method Get_Next_Definition(..) reads a line of text from a configuration file and returnes two strings of data. The second string is to be put in the map
void C_Configuration_Manager::Populate_Parameter_Map( td_map_parameter_names * pmap_message_parameters )
{
td_message_parameter_number parameter_number = 1;
td_msg_parameter_name cannot_use;
string expected;
string t_string;
bool call_status;
do{
expected = "Parameter";
call_status = Get_Next_Definition( &expected, &t_string );
if( t_string != "End" )
{
// cannot_use( t_string.c_str() ); // why not, secondary question
td_msg_parameter_name local_parameter_name( t_string.c_str() );
// this compiles
// I check the help file and added this just to test it. No compile error
pmap_message_parameters ->insert( map<int, CString>:: value_type( pararmeter_number, local_parameter_name ) );
// This is my problem line.
pmap_message_parameters[ parameter_number ] = local_parameter_name;
}
} while( t_string != "End" );
}
the error returned is: Error 1 error C2697: binary "=' : no operator found which takes a right-hand operand of type 'td_msg_parameter_name' (or there is no acceptable conversion)
Sorry to be unclear (I usualy am to some degree): On line 23, I guess you don't have a copy constructor or operator = for pmap_message_parameters, so the compiler says there isn't one. Try this for the line:
Error 1 error C2697: binary "=' : no operator found which takes a right-hand operand of type 'td_msg_parameter_name *' (or there is no acceptable conversion)
As I look at the map declaration I don't see that there is a pointer involved. I presume that it will take the local_parameter_name as "by value" (as opposed to "by ref" or "by address") and copy local_parameter_name into the map. I am still seeing this as a declaration problem and don't understand my error.
Edit:
I backed up to the method where I created the map and tried to insert a simple value. That looks like this:
1 2 3 4 5 6 7 8 9 10 11 12 13
// I start with a structure for a message. The message contains multiple parameters.
// the goal is to create a map for those parmeters and use the parameter number
// as the key into the map.
p_message_definition->pmap_message_pararmeters = new ( td_map_parameter_names );
// Create test data to put in the map
td_msg_parameter_name stuff = _T("stuff" )
td_msg_parameter_number parameter_number = 1;
// Now try to add a single entry into the map
p_message_definition->pmap_message_pararmeters[ parameter_number ] = stuff;
Did that simplify the question or did I just add an error on top of another error?
Add in the parens and it compiled. But then, I still didn't have what I needed. I eventually detrermined that I really needed to pass an pointer pointer to a function so it could give me a pointer to the map.
Just a few days ago I worked with one doing CreateDIBSection and figured out what that really means. Then yesterday I saw that I needed just that and and was able to create it.
You're most welcome bkelly! These pointer to pointer issues always seem to bite me. You'ed think I would have it down since I've been programming in C since 1986 and C++ since 1991. Sheesh!