I need to pass by reference so that the object changes its value after returning.
this is the code that I assume would function properly.
//print.h
void Path( std::map<std::string, std::string>& path );
..
..
//parameter.h
std::map<std::string, std::string> GetParameter(){
return fieldData;
};
..
..
//main
main(){
print::Instance().Parameter( parameter.GetParameter() );
}
However, end up with a compile error.
new_shenu.cpp:18: error: no matching function for call to `Print::Parameter(std::map<std::string, std::string, std::less<std::string>, std::allocator<std::pair<const std::string, std::string> > >)'
Print.h:37: note: candidates are: void Print::Parameter(std::map<std::string, std::string, std::less<std::string>, std::allocator<std::pair<const std::string, std::string> > >&)
Why?
well, I've seen some people use the const keyword, so I tried
//print.h
void Path( const std::map<std::string, std::string>& path );
..
..
and i was successful in compiling but I know then I won't be able to change the data.