我刚刚开始使用C++进行编程,并且正在使用模板。这段C++代码有什么问题?
以下代码在运行时失败,我不知道为什么。 (请注意,这只是一个示例代码和在生产中不使用)
bool maxCompare(string* s1,string* s2){
cout<<*s1<<endl;
cout<<*s2<<endl;
return true; //If I comment this line and instead use the line below, it works fine.
//return *s1 < *s2;
}
int main()
{
string* s1=new string("Hello");
string* s2=new string("Hi");
string *s3= max(s1,s2,maxCompare);
}
'G ++ -g -Wall source.cpp'比'GDB/a.out'和GDB:'run'比'bt'当它失败......或者,如果你”足够geeky:'开始; S; S; S; ;?s ...':) – Vyktor 2012-02-13 13:03:25
什么是'max' ... – 2012-02-13 13:05:40
哪个编译您使用的?你不能在调试模式下在MSVC上执行此操作 – mkaes 2012-02-13 13:06:41