草庐IT

base_conversion

全部标签

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

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

c++ - Qt : After installation of VS2012 LNK1123 failure during conversion to COFF

之后我安装了VS2012我的Qt项目不再编译(我的电脑上有VS2010和VS2012)。消息:LNK1123:转换为COFF期间失败:文件无效或损坏。以前只用VS2010没问题。对于VS2012环境,建议(参见SOhere):使用EnableIncrementalLinkingNO编译卸载.net4.5因为我没有将Qt与VS2012结合使用(所以没有插件),所以我不能setuptheprojectasmentioned.我也不能卸载.net4.5(另一个项目需要)。有机会解决这个问题吗?我有一些相关的问题是否可以针对VS2012C++编译器进行编译?Hereitsays为此,我需要自己

c++ - 如果 Derived 不向 Base 添加新成员(并且是 POD),那么可以安全地完成什么样的指针转换和取消引用?

(这是关于未定义行为(UB)的另一个问题。如果这段代码在某些编译器上“有效”,那么这在UB领域就没有任何意义。这是可以理解的。但是我们到底在下面的哪一行跨入UB?)(关于SO已经有很多非常相似的问题,例如(1)但我很好奇在取消引用指针之前可以安全地使用指针做什么。)从一个非常简单的基类开始。没有virtual方法。无继承。(也许这可以扩展到任何POD?)structBase{intfirst;doublesecond;};然后是添加(非virtual)方法但不添加任何成员的简单扩展。没有virtual继承。structDerived:publicBase{intfoo(){return

c++ - Boost Program_Options 抛出 "character conversion failed"

我在Ubuntu14.04上,使用CMake和CLion。我正在尝试使用程序选项,以下代码取自其文档中的示例:#include#includeintmain(intac,char*av[]){namespacepo=boost::program_options;usingnamespacestd;po::options_descriptiondesc("Allowedoptions");desc.add_options()("help","producehelpmessage")("compression",po::value(),"setcompressionlevel");po::

c# - "C# base class virtual function"- "override in Managed C++ ref class"

我有一个.NET_4ManagedC++ref类,它派生自用C#编写的.NET_4基类。C#基类:namespaceCore{publicclassResourceManager{publicclass_Resource{publicvirtualvoidDelete(){}}}}托管C++类:namespaceInput.DI{publicrefclassMouse:ResourceManager::_Resource{public:virtualvoidDelete(){}};}这是我遇到的错误:'Input::DI::Mouse::Delete':matchesbaserefcl

C++ 惯用法之 Policy-based design

一、背景Policy-based是C++的一种基于模板和继承的设计方法。通过模板方式可以实现在编译期给指定的类配置方法,而传统的策略模式则是在运行期对类的方法进行动态配置。所谓设计模式没有一定不变的使用准则,同一个问题可以有多种模式来解决,采用有效的设计模式可以减少重复性代码以及用最小的改动来应对变化。多了解一种模式,可以增加一种解决问题的思路。二、Policy-baseddesign1.概述该模式中的继承是implement-by的关系,而非Is-A的关系,其重点是模板而非继承。2.问题描述假设一个类提供一个对外的接口,但在不同的场景中有不同的实现方式,以下是一种常见的实现代码:classd

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++ - 错误 C2504 : 'BASECLASS' : base class undefined

我查看了一个与此类似的帖子,但链接不同,问题从未得到解决。我的问题是,出于某种原因,链接器期望有一个基类的定义,但基类只是一个接口(interface)。以下是完整的错误c:\users\numerical25\desktop\introtodirectx\godfiles\gxrendermanager\gxrendermanager\gxrendermanager\gxdx.h(2):errorC2504:'GXRenderer':baseclassundefined下面是显示标题如何相互链接的代码GXRenderManager.h#ifndefGXRM#defineGXRM#in

c++ - 错误 : invalid conversion from 'void (*)()' to 'void (*)()' -- what?

我正在尝试将回调函数从C++传递到OpenGL(CAPI):gluQuadricCallback(qobj,GLU_ERROR,errorCallback);其中errorCallback是编译为C++代码的文件中的函数,声明为voiderrorCallback();代码在Linux上使用g++4.4编译干净,但在Windows上使用mingw32g++4.4时出现以下错误:..\glwidget.cpp:172:error:invalidconversionfrom'void(*)()'to'void(*)()'..\glwidget.cpp:172:error:initializi

c++ - 错误 C2678 : binary '=' : no operator found which takes a left-hand operand of type 'const Recipe' (or there is no acceptable conversion)

我正在尝试对每个元素中包含一个int和一个字符串的vector进行排序。它是一个称为vector食谱的类类型的vector。出现上述错误,这是我的代码:在我的Recipe.h文件中structRecipe{public:stringget_cname()const{returnchef_name;}private:intrecipe_id;stringchef_name;在我的Menu.cpp文件中voidMenu::show()const{sort(recipes.begin(),recipes.end(),Sort_by_cname());}在我的Menu.h文件中#include