草庐IT

ambiguous

全部标签

c++ - SFINAE 没有避免模棱两可的调用

编译这段代码:#includetemplatestructTestClass{template::type=0>voiddoAction(){std::cout();\n";}};structHostClass:publicTestClass,publicTestClass{};intmain(intargc,constchar*argv[]){HostClasshostClass;hostClass.doAction();hostClass.doAction();return0;}导致不明确的调用错误,因为doAction都在TestClass中和TestClass父类。main.c

c++ - Visual Studio 2017 : ambiguous symbol size_t in linux projects

在VisualStudio2017中创建Linux项目并在源代码中插入usingnamespacestd;时,如下所示:#include#includeusingnamespacestd;intmain(){size_ti=1;strings=to_string(i);coutVS下划线size_t说是有歧义的符号。如果我按F12(转到定义),它会为我提供两个定义位置:来自stddef.h(C:\ProgramFiles(x86)\MicrosoftVisualStudio14.0\VC\Linux\include\usr\include\x86_64-linux-gnu\5\incl

c++ - g++ 和 clang++ - 删除重载转换运算符歧义获取的指针

我试图发布此代码作为对thisquestion的回答,通过制作这个指针包装器(替换原始指针)。这个想法是将const委托(delegate)给它的指针,这样filter函数就不能修改值。#include#includetemplateclassmy_pointer{T*ptr_;public:my_pointer(T*ptr=nullptr):ptr_(ptr){}operatorT*&(){returnptr_;}operatorTconst*()const{returnptr_;}};std::vector>filter(std::vector>const&vec){//*vec.

c++ - 在 C++ 中调用函数是不明确的。候选函数是原型(prototype)和函数本身

我正在完成StanfordCS106BC++作业,但作业存在“语义问题”。编译器似乎无法推断调用是针对函数还是函数原型(prototype)。我不明白为什么会调用原型(prototype)。我怎样才能做到调用函数而不是原型(prototype)?我收到的错误消息是“调用‘humansTurn’不明确”。错误消息与页面底部humanTurn(Lexicon,Lexicon)函数内的humanTurn(Lexicon,Lexicon)函数的调用有关。该函数的原型(prototype)在主函数之上。如有任何帮助,我们将不胜感激。亲切的问候,梅胡尔/**File:Boggle.cpp*----

c++ - 错误 : ambiguates old declaration ‘double round(double)’

/usr/include/i386-linux-gnu/bits/mathcalls.h:311:1:error:ambiguatesolddeclaration‘doubleround(double)’g.cpp:Infunction‘intround(double)’:g.cpp:14:24:error:newdeclaration‘intround(double)’/usr/include/i386-linux-gnu/bits/mathcalls.h:311:1:error:ambiguatesolddeclaration‘doubleround(double)’#includ

c++ - 模板扣减申诉模棱两可的候选人

我打算实现我的“稀疏vector”和“vector”类的乘法运算符。以下简化的代码演示显示了我的问题Vector.hpp中的Vector类#pragmaoncetemplateclassVector{public:Vector(){}templatefriendVectoroperator*(constScalar&a,constVector&rhs)//#1{returnVector();}};SpVec.hpp中的稀疏vector类#pragmaonce#include"Vector.hpp"templateclassSpVec{public:SpVec(){}templatein

c++ - "Ambiguous conversion sequence"- 这个概念的目的是什么?

在N465916.3.3.1隐式转换序列中说10Ifseveraldifferentsequencesofconversionsexistthateachconverttheargumenttotheparametertype,theimplicitconversionsequenceassociatedwiththeparameterisdefinedtobetheuniqueconversionsequencedesignatedtheambiguousconversionsequence.Forthepurposeofrankingimplicitconversionsequen

c++ - 多重继承引起的C++拷贝构造函数调用不明确

我在执行某项任务时遇到了问题,这是一个练习,而不是一个真正的程序。任务是定义结构D的复制构造函数,其行为方式与编译器生成的复制构造函数完全相同。classOb{};structA{Oba;};structB:A{Obb;};structC:A,B{Obc;};structD:C,A{Obd;};如您所见,结构A在结构D中间接派生了几次,这导致了复制构造函数定义中的歧义,如下所示:D(constD&_d):C(_d),A(_d),d(_d.d){}我的问题是如何正确定义复制构造函数?没有上述定义的代码编译通过,所以看起来应该是可以的。MinGW4.8.1错误信息:zad3.cpp:12:

c++ - 铿锵错误 : ambiguous conversion for static_cast

我有以下代码:typedefintAliasB;typedefunsignedshortAliasA;classAlias{public:explicitAlias(intsomeInt){}};//(*)!!belowbreakstheconversionpathviaAliasA!!//typedefAliasAliasA;classC{public:C(){}};classB{public:B(){}B(constAliasB&value){}operatorAliasB()const{return-1000;}Ccombine(constB&someB){returnC();}

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