草庐IT

SCAN_POINTER_START

全部标签

c++ - 错误 : called object type 'int' is not a function or function pointer

我在这里写了一个快速排序:voidswap(int&a,int&b);intmid(intlo,inthi);//Myquicksortimplementationvoidsort(intvec[],intlo,inthi){intmid;if(hi>lo){inti=lo+1;intj=hi;intp=mid(lo,hi);swap(vec[lo],vec[p]);mid=vec[lo];while(i=mid);swap(vec[i],vec[j]);}}i++;swap(vec[lo],vec[i]);sort(vec,lo,i);sort(vec,j,hi);}}voidswa

c++ - 错误 : called object type 'int' is not a function or function pointer

我在这里写了一个快速排序:voidswap(int&a,int&b);intmid(intlo,inthi);//Myquicksortimplementationvoidsort(intvec[],intlo,inthi){intmid;if(hi>lo){inti=lo+1;intj=hi;intp=mid(lo,hi);swap(vec[lo],vec[p]);mid=vec[lo];while(i=mid);swap(vec[i],vec[j]);}}i++;swap(vec[lo],vec[i]);sort(vec,lo,i);sort(vec,j,hi);}}voidswa

c++ - 使用空大括号初始化程序 : pointer or reference? 的重载分辨率

这个问题在这里已经有了答案:Overloadresolution:assignmentofemptybraces(2个回答)关闭5年前。当我发现下面的代码输出“指针”时,我遇到了一个真实的WTF时刻。#include#includetemplatestructbla{staticvoidf(constT*){std::cout>::f({});}更改std::pairint的模板参数或任何其他原始类型,给出(至少对我而言)预期的“模棱两可的重载”错误。似乎内置类型在这里很特殊,因为任何用户定义的类型(聚合、非平凡、具有默认构造函数等)都会导致调用指针重载。我相信模板不是复制它的必要条件

c++ - 使用空大括号初始化程序 : pointer or reference? 的重载分辨率

这个问题在这里已经有了答案:Overloadresolution:assignmentofemptybraces(2个回答)关闭5年前。当我发现下面的代码输出“指针”时,我遇到了一个真实的WTF时刻。#include#includetemplatestructbla{staticvoidf(constT*){std::cout>::f({});}更改std::pairint的模板参数或任何其他原始类型,给出(至少对我而言)预期的“模棱两可的重载”错误。似乎内置类型在这里很特殊,因为任何用户定义的类型(聚合、非平凡、具有默认构造函数等)都会导致调用指针重载。我相信模板不是复制它的必要条件

c++ - 常量不匹配 : 2 overloads have no legal conversion for 'this' pointer

我收到了这个奇怪的错误:errorC2663:'sf::Drawable::SetPosition':2overloadshavenolegalconversionfor'this'pointer我认为这与const不匹配有关,但我不知道在哪里,或者为什么。在下面的代码中,我有一个形状和Sprite的vector,当尝试访问其中一个vector形状并调用它的一个函数时,我遇到了错误。std::vectorShapes;std::vectorSprites;boolAddShape(sf::Shape&S){Shapes.push_back(S);returntrue;};boolAdd

c++ - 常量不匹配 : 2 overloads have no legal conversion for 'this' pointer

我收到了这个奇怪的错误:errorC2663:'sf::Drawable::SetPosition':2overloadshavenolegalconversionfor'this'pointer我认为这与const不匹配有关,但我不知道在哪里,或者为什么。在下面的代码中,我有一个形状和Sprite的vector,当尝试访问其中一个vector形状并调用它的一个函数时,我遇到了错误。std::vectorShapes;std::vectorSprites;boolAddShape(sf::Shape&S){Shapes.push_back(S);returntrue;};boolAdd

c++ - 编译错误 : Undefined symbols: "_main", 引用自 : start in crt1. 10.5.o

我有以下代码:#includeusingnamespacestd;classtesting{inttest()const;inttest1(consttesting&test2);};inttesting::test()const{return1;}inttesting::test1(consttesting&test2){test2.test();return1;}编译后出现如下错误:Undefinedsymbols:"_main",referencedfrom:startincrt1.10.5.old:symbol(s)notfoundcollect2:ldreturned1exi

c++ - 编译错误 : Undefined symbols: "_main", 引用自 : start in crt1. 10.5.o

我有以下代码:#includeusingnamespacestd;classtesting{inttest()const;inttest1(consttesting&test2);};inttesting::test()const{return1;}inttesting::test1(consttesting&test2){test2.test();return1;}编译后出现如下错误:Undefinedsymbols:"_main",referencedfrom:startincrt1.10.5.old:symbol(s)notfoundcollect2:ldreturned1exi

c++ - 如何将 "pointer to pointer type"转换为 const?

用下面的代码voidTestF(constdouble**testv){;}voidcallTest(){double**test;TestF(test);}我明白了:'TestF':cannotconvertparameter1from'double**'to'constdouble**'我不明白为什么。为什么test不能被无声地转换为constdouble**?我为什么要明确地这样做?我知道TestF(const_cast(test))使我的代码正确,但我觉得这应该是不必要的。我缺少一些关于const的关键概念吗? 最佳答案 该

c++ - 如何将 "pointer to pointer type"转换为 const?

用下面的代码voidTestF(constdouble**testv){;}voidcallTest(){double**test;TestF(test);}我明白了:'TestF':cannotconvertparameter1from'double**'to'constdouble**'我不明白为什么。为什么test不能被无声地转换为constdouble**?我为什么要明确地这样做?我知道TestF(const_cast(test))使我的代码正确,但我觉得这应该是不必要的。我缺少一些关于const的关键概念吗? 最佳答案 该