I overloaded a function like the following:
void myClass::saveAsMat (bool complete){
...
}
void myClass::saveAsMat (std::string filename){
...
}
In my main.cpp when I call the function like this:
myObj.saveAsMat(true);
everthing works fine. But when I instead call the function like this:
myObj.saveAsMat("myName");
the function is not being executed at all. I expected a compile or runtime error but there is nothing like that. The program gets compiled and runs only that the function is ignored. (I checked this by placing some std::cout
inside the function).
Then I found out that I can solve this by changing the argument passed to:
myObj.saveAsMat(string("myName"));
Why do I have to set the extra string()
for the argument? Other functions that are not overloaded are working fine by simply passing "myName"
for a "std::string"
paramenter.