Visual C ++ 2010 accepts a string for bool in an overloaded function

I use Visual Studio 2012 (but using the VC ++ 2010 build tools), and I have these two overloaded functions (signatures below) defined in the class, which I later call in another class that instantiates the first class (also below)

Defined in the class:
Node CreateNode(Node *parent,string name,string node_text,bool expects_node = true);
Node CreateNode(Node *parent,string name, string attribute, string value,bool expects_node = true)

Calling these functions in the macro:
Node axis1 = handler->CreateNode(&sparse,"axis","id","trigger_pt");

When I call a function call, it calls the first function, not the second! Therefore, it treats the second line as a logical one! However, when I add "true" to the function call, it calls the second function as expected. Can someone explain this? Thank!

+5
source share
1 answer

"trigger_pt" " 11 const char". , bool, std::string. , bool ( , bool), std::string . , ( ).

( 13.3.3.1)

  • (13.3.3.1.1) , ,
  • [...]

, a std::string:

Node axis1 = handler->CreateNode(&sparse,"axis","id",std::string("trigger_pt"));

, const char*, bool. std::string.

+7

All Articles