草庐IT

Overloaded

全部标签

c++ - 错误 : no instance of overloaded function "std::make_shared" matches the argument list

查看ApreviousstackQuestionstd:make_sharedvsstd::shared_ptr,我试图在一个uni项目中实现它。这是之前的“问题”:Ican'tthinkofanysituationwherestd::shared_ptrobj(newObject("foo",1));wouldbepreferredtoautoobj=std::make_shared("foo",1);因此我采用了这段代码:std::shared_ptrpT1(newTriangle(pCanvas,30,30,30,60,60,30,255,0,0));并将其修改为这段代码:aut

c++ - "unresolved overloaded function type"在 std::function 中有静态函数

尝试将重载静态函数传递给std::function时出现“未解析的重载函数类型”错误。我知道类似的问题,例如this和this.然而,即使那里的答案可以将正确函数的地址放入函数指针中,它们也会因std::function而失败。这是我的MWE:#include#include#includestructClassA{staticstd::stringDoCompress(conststd::string&s){returns;}staticstd::stringDoCompress(constchar*c,size_ts){returnstd::string(c,s);}};voidh

c++ - "no matching function for call to ‘async(std::launch, <unresolved overloaded function type>, std::string&)’“

我正在尝试使用std::async创建线程,但我不断收到错误“没有匹配函数调用‘async(std::launch,,std::string&)’”在行上ConnectFuture=std::async(std::launch::async,Connect_T,ip);这是产生这种行为的代码:#includeclasslibWrapper{public:voidConnect(std::stringip);voidConnect_T(std::stringip);private:std::futureConnectFuture;};voidlibWrapper::Connect(std

c++ - 为什么不允许使用 "second C linkage of overloaded function"?

我将我的C++dll转换为Cdll:#ifdef__cplusplusextern"C"{#endifMY_EXPORTintmy_func();MY_EXPORTvoidmy_func(intn);#ifdef__cplusplus}#endif没有externC声明一切正常。有了这个声明,我得到了errorC2733:secondClinkageofoverloadedfunction'my_func'notallowed为什么不允许从C风格的dll导出重载函数? 最佳答案 C不允许重载函数。那就是C不支持重载。这是C++的一个

c++ - 'more than one instance of overloaded function "sqrt“匹配参数列表”怎么办?

我的代码在for循环中出错,for(j=3;j:morethanoneinstanceofoverloadedfunction"sqrt"matchestheargumentlist.我该如何解决?#include//determineifnumberisprimeboolisPrime(longn){intj,num=0;{if(num 最佳答案 尝试:for(j=3;j(num));j+=2)发生的事情是包含3个不同的definitionsofsqrt并且编译器不知道您要使用哪个。

c++ - 编译错误 : unresolved overloaded function type

我尝试用g++4.7.2编译以下内容:templatestructA{structB{Tt;templateTget(){returnthis->*M;}};Bb;Tget(){returnb.get();}};intmain(){Aa;a.get();}它给了我test.cpp:Inmemberfunction‘TA::get()’:test.cpp:15:23:error:expectedprimary-expressionbefore‘)’tokentest.cpp:Ininstantiationof‘TA::get()[withT=int]’:test.cpp:22:8:req

c++ - 错误 C2731 : 'wWinMain' : function cannot be overloaded

我将一个旧项目从VC6升级到VS2008,现在我得到这个编译错误:errorC2731:'wWinMain':functioncannotbeoverloaded在这些代码行:intAPIENTRY_tWinMain(HINSTANCEhInstance,HINSTANCEhPrevInstance,LPSTRlpCmdLine,intnCmdShow)同一项目在VC6下编译良好。 最佳答案 谢谢大家,我终于找到了真正的罪魁祸首,这是一个错字,我使用LPSTRlpCmdLine而不是LPTSTRlpCmdLine。真正的谜团是为什么

c++ - C2556 : overloaded function differs only by return type

我正在阅读EffectiveC++,它告诉我“可以重载仅因常量不同而不同的成员函数”。书中的例子是:classTextBlock{public:constchar&operator[](std::size_tposition)const;char&operator[](std::size_tposition);private:std::stringtext;}我下面的示例使用了一个存储指针。classA{public:A(int*val):val_(val){}int*get_message(){returnval_;}constint*get_message(){returnval_

c++ - 继续获取 "error: use of undeclared identifier ' cout' 和错误 : reference to overloaded function could not be resolved

我正在编写一个使用许多不同函数的排序程序,你们都可以从我的声明。但是,当我尝试编译和运行我的程序时,我不断遇到这些相同的错误它们如下:error:useofundeclaredidentifier'cout';didyoumean'count'?couterror:referencetooverloadedfunctioncouldnotberesolved;didyoumeantocallit?couterror:useofundeclaredidentifier'endl';didyoumean'end'?cout我不太确定为什么会出现这些错误....我想我已经包含了我需要的一切为

c++ - "No viable overloaded ' = ' "为什么?

我正在为我的一门类(class)做一个项目,我很确定我几乎完成了这个项目。基本上我必须输入2人的票,我必须找到最高价和最低价。我需要重载*和/运算符来解决该项目的问题。此外,根据老师的指示,friend声明对于该项目来说是必需的。现在,对于这个问题。我正在尝试将正确的票证变量(t1或t2)存储到t3中,以便我可以将其返回给主变量。当我使用“=”将t1设置为t3时,它说“没有可行的重载'='”。以下是我的代码:#includeusingnamespacestd;classticket{public:ticket();doubleinput();doubleoutput();friendt