If something does not compile, then it surely does not have valid syntax. (Note that logically wrong code could compile just fine.)
When something does not compile, the compiler does give an explanation -- an error message.
We can't explain you the explanation, if you don't show it.
However, lets look at:
1 2
|
std::map<std::string,Base> abd;
abd.insert( "banana", "mongo" );
|
Is that how one inserts to map?
Lets see:
http://www.cplusplus.com/reference/map/map/insert/
The answer is clearly "no".
Now, lets look at other details:
1 2 3 4 5 6 7 8 9
|
class child : public map<string,BASE>
{
// ...
void Add( Base b ) {
map<string,Base> abd;
abd.insert( "banana", "mongo" );
}
// ...
};
|
BASE
is not
Base
. Could be just a rushed typo. Those are nasty.
The function takes parameter
b. Why? It is not used in the function.
The function creates a local map variable
abd
. That map is destroyed at the end of the function Add. The function does not change the state of
child
object in any way.
The child is a map. If child is a map, then why doesn't Add() add elements to child? One could have:
1 2 3
|
child example;
Renseignements sample;
example.insert( std::pair<string,BASE>( "banana", BASE("mongo", sample) ) );
|