草庐IT

called_number

全部标签

c++ - 使用 float 给出 "call to overloaded function is ambiguous"错误

这个问题在这里已经有了答案:Referencetofunctionisambiguous[duplicate](2个答案)关闭6年前。我正在重载函数add(),但是当我使用float数据类型时它显示错误。但是,当我将其更改为double时,它工作正常。为什么float会导致错误?代码是:#includeusingnamespacestd;classstudents{private:inti;floatf;public:voidadd(intb){i=b;cout错误:Infunction'intmain()':[Error]callofoverloaded'add(double)'is

c++ - 为什么这个 "call"断言看到两个参数而不是一个?

给定thistestprogram:#include#include#includeconststd::string&const_string="bla";std::stringconst&string_const="blabla";static_assert(std::is_same::value,"Uhoh");intmain(){assert(std::is_same::value);}它使用C的断言断言两种类型在编译时和运行时相同。所有Clang、MSVC2015和GCC都报告相同的错误,所以我很确定it'sme:main.cpp:13:49:error:toomanyargu

C++ googlemocks : Getting a stack trace of an uninitialized call

模拟类看起来像这样:构造模拟类{MOCK_METHOD0(foo,void());};如果我忘记在模拟对象上设置预期的调用,我会得到这样的结果:GMOCKWARNING:Uninterestingmockfunctioncall-returningdirectly.Functioncall:foo()Stacktrace:并且堆栈跟踪为空。那么,为了获取堆栈跟踪必须做什么? 最佳答案 这描述了here:YoucancontrolhowmuchGoogleMocktellsyouusingthe--gmock_verbose=LEVE

C++ : Calling a child method from parent instantiation

在我的代码中,我实现了这些类:classA{public:virtualintfun(){return0;}}classB:publicA{public:virtualintfun(){return1;}}还有这些函数:voidoperation(Aa){printf("%d\n",a.fun());}intmain(){Bb;operation(b);return0;}可以看到,B类继承了A类,并实现了虚继承方法fun()。主类调用一个以A为参数的函数,并调用fun()方法,参数为B对象。在执行时,我希望打印字符串"1",但它是"0"(即使它是传递给的B对象操作()).我需要这样做,

c++ - GMock - 使用 ON_CALL 为重载方法返回默认值

我正在尝试为包含三个重载方法的类编写模拟,即:#include#includeusing::testing::_;using::testing::Return;using::testing::A;using::testing::ByRef;using::testing::Ref;using::testing::TypedEq;structFoo{intfooMethod(constint&intParam){return0;}intfooMethod(constfloat&floatParam){return0;}intfooMethod(conststd::string&string

c++ - Qt 5.5 与 qmake : Linker cannot resolve OpenGL function calls

当使用Qt5.5、qmake和MSVC13编译带有一些基本OpenGL函数调用的基本样板Qt应用程序时,出现以下链接器错误:glwidget.obj:-1:error:LNK2019:unresolvedexternalsymbol__imp__glClear@4referencedinfunction"public:virtualvoid__thiscallGLWidget::initializeGL(void)"(?initializeGL@GLWidget@@UAEXXZ)glwidget.obj:-1:error:LNK2019:unresolvedexternalsymbol

【git问题处理】SSL routines:ssl3_get_record:wrong version number问题解决小记

🐚作者简介:花神庙码农(专注于Linux、WLAN、TCP/IP、Python等技术方向)🐳博客主页:花神庙码农,地址:https://blog.csdn.net/qxhgd🌐系列专栏:GitHub开源📰如觉得博主文章写的不错或对你有所帮助的话,还望大家三连支持一下呀!!!👉关注✨、点赞👍、收藏📂、评论。如需转载请参考转载须知!!SSLroutines:ssl3_get_record:wrongversionnumber问题解决小记问题描述问题分析问题解决命令汇总全局代理——所有git命令都走此代理全局代理——针对特定域名设置代理局部代理——仅针对某仓库设置代理问题描述gitclone--br

c++ - 如何在 Lua 5.2.3 中将 lua_number 从 double 正确更改为 float

我希望lua_number得到一个float而不是double。我知道我必须更改luaconf.h中的某些内容,但我不知道是什么。我正在使用Lua5.2.3和VisualStudioC++。 最佳答案 您需要编辑luaconf.h并更改这些:LUA_NUMBER到floatLUA_NUMBER_SCAN到"%f"LUA_NUMBER_FMT到"%.7g"l_mathop(x)到(x##f)lua_str2number使用strtof对于最后两个,您可能需要一个支持(部分)C99标准的C编译器。

c++ - 错误 : pure virtual method called - terminate called without an active exception - Aborted

在我的A.h文件中:classA{private:unsignedshortPC;public:A():PC(0){}virtual~A(){}virtualvoidexecute(unsignedshortPC)=0;};在我的B.h文件中:classB:publicA{private:intstatus;boolexe;public:B:status(0),exe(false){}virtualB(){}voidexecute(unsignedshortPC);};在我的B.cpp文件中:#include#include"B.h"voidB::execute(unsignedsho

C++ 临时 - "pure virtual method called"

据我所知,下面的代码应该可以工作,但实际上没有。structbase{virtual~base(){}virtualvoidvirt()const=0;};structderived:publicbase{virtualvoidvirt()const{}};constbase&foo(){returnderived();}intmain(){foo().virt();return0;}调用virt()会出现“调用纯虚函数”错误。为什么会这样,我该怎么办? 最佳答案 您正在返回对临时对象的引用,该引用在return结束时函数结束时被破