草庐IT

initialize-assemblies-using-preap

全部标签

c++ - 海湾合作委员会 : C++11 inline object initialization (using "this") does not work when there is a virtual inheritance in hierarchy

当在初始化中使用此指针并且在层次结构中存在虚拟继承时,C++11内联对象初始化不起作用(在GCC中)。这可能是GCC的错误吗(因为它在CLang中工作)?还是C++11标准本身的差距?示例(可以在here中尝试),当使用GCC编译以下代码时:FieldIndexm_inB{"inB",this};不会被执行。但它会在使用CLang编译时执行。变通方法:从FieldIndexContainer派生A作为虚拟#include#include#includeusingnamespacestd;classFieldIndexContainer{public:classFieldIndex{pu

c++ - initializer_list函数重载的解决

#includeusingnamespacestd;classA{public:explicitA(constinitializer_list&a){}};voidfunc(constvector&a){}voidfunc(Aa){}intmain(void){func({1,2,3});}此代码编译失败:(19):errorC2668:'func':ambiguouscalltooverloadedfunction(13):note:couldbe'voidfunc(A)'(9):note:or'voidfunc(conststd::vector>&)'with[_Ty=int](1

c++ - 在我的命名空间中公开外部库类时使用 typedef 或 using 关键字

我想将外部库中的类公开给我库的用户。具体来说,我想将类“导入”到我的命名空间中,这样用户就不需要知道我在幕后使用的是什么库。通常,我似乎可以通过使用typedef或简单地通过using类来完成此操作。是否有任何理由选择一种方法而不是另一种方法(或做其他事情)?(我的学历好像有点差距:))例如:我想创建一个使用Boost::Asio的串口管理器。namespaceMySerialManager{//shouldIuseatypedeftypedefboost::asio::serial_port_base::flow_controlflow_control;//orausing...us

Spring Boot 报错:Web server failed to start. Port 8080 was already in use.

报错信息:Webserverfailedtostart.Port8080wasalreadyinuse报错原因:端口被占用。解决方法:解决方法一:修改端口;         修改配置文件,加上参数:server.port=8014解决方法二:关闭占用端口的进程。    1.使用cmd命令查看端口号占用情况,例如查看端口8014,可以看出进程号为10728;        netstat-ano|findstr端口号        2.关闭该进程        方法一:使用任务管理器关闭:        菜单栏->右键->任务管理器->详细信息,根据PID排序找到PID为10728的进程,选择后

Name for argument of type [java.lang.String] not ... Ensure that the compiler uses the ‘-parameters’

更多信息:https://oldmoon.top/post/191简介使用最新版的Springboot3.2.1搭建开发环境进行开发,调用接口时出现奇怪的错。报错主要信息如下:Nameforargumentoftype[java.lang.String]notspecified,andparameternameinformationnotavailableviareflection.Ensurethatthecompilerusesthe‘-parameters’flag.官方说明中一直强调@PathVariable的使用,并没有提及@RequestParam,阅读官方文档@RequestPa

c++ - 警告 : base class ‘A’ should be explicitly initialized in the copy constructor

我有以下类结构:classA{A(){}A(constA&src){}};classB:virtualA{B():A(){}B(constB&src):A(src){}};classC:virtualA{C():A(){}C(constC&src):A(src){}};classD:virtualB,virtualC{D():B(),C(){}D(constD&src):B(src),C(src){}};这给了我警告:Incopyconstructor‘D’:warning:baseclass‘A’shouldbeexplicitlyinitializedinthecopyconstr

c++ - 错误 : Invalid use of incomplete type struct Subject; error: forward declaration of struct Subject

我继承自模板类。当我进入教师类(class)时,我想进入学科类(class),反之亦然。我收到错误InvaliduseofincompletetypestructSubect;voidaddSubject(Subject*s){this->addReference(s);s->addReference(this);whenIcommentthislinetheitcompileswithouterrors,butIcannotinsertintoSubject}我的全部代码在下面#include#include#includeusingnamespacestd;classSubject

c++ - 为什么我收到错误 "non-template ' f' used as template”

我正在尝试了解在哪里使用template和typename我遇到了一个我无法完全解决的问题。我有一个模板函数f它使用传递给它的类型(将是一个类)来调用模板成员函数.f.我想我使用typename在函数体中是正确的,但是,我不断收到以下错误:source.cpp:Infunction'voidf()':source.cpp:11:19:error:non-template'f'usedastemplatesource.cpp:11:19:note:use'typenameT::C::templatef'toindicatethatitisatemplatestructA{structC{

c++ - 这个 "CRT not initialized"错误是怎么回事?

我在VisualStudio2012Express(当然是桌面版)中创建了一个空的C++项目,并添加了一些随机的基本代码:#include#includetypedefstructexamplestruct{unsignedcharnum1;unsignedshortnum2;unsignedlongnum3;unsignedlonglongnum4;}EXAMPLESTRUCT;voidexamplefunction(unsignedlong*num,intnum2){*num+=num2;return;}intmain(intnArgs,char**pszArgs){EXAMPLE

c++ - std::initializer_list<> 和一个引用参数

我刚开始使用初始化列表,我想知道它们的工作方式是否与其他STL容器相似。我的意思是他们复制值(value)观吗?我想做的是一个简单的min()函数,如下所示:templateT&minArgs(conststd::initializer_list&Arguments){constT*Smallest=Arguments.begin();for(constT*I=begin(Arguments);I!=end(Arguments);++I){if(*I然而,当我调用函数时,我从GCC得到了这个:error:'const'qualifierscannotbeappliedto'int&'我