In msvc, I have functions like this and it builds, but in gcc he doesn't like it.
void classname::a(std::string &text)
{
stdStringFromClass = text;
}
void classname::b(char *text)
{
a(std::string(text));
}
The problem here is &, gcc. I think it is worrying that since I just created this std :: string, passing by reference is risky, so it is not created, but msvc does not even warn me.
Why is this incorrect C ++ for gcc I keep hearing that msvc is more strict than gcc.
thank
Error
AguiWidgetBase.cpp: In member function ‘void AguiWidgetBase::setText(char*)’:
AguiWidgetBase.cpp:91:27: error: no matching function for call to ‘AguiWidgetBase::setText(std::string)’
AguiWidgetBase.cpp:80:6: note: candidates are: void AguiWidgetBase::setText(std::string&)
AguiWidgetBase.cpp:88:6: note: void AguiWidgetBase::setText(char*)
this will be good?
void classname::a(std::string &text)
{
stdStringFromClass = text;
}
void classname::b(char *text)
{
std::string k = text;
a(k);
}
source
share