草庐IT

unowned-references

全部标签

c++ - undefined reference 和非虚拟 thunk

这个问题不太可能帮助任何future的访问者;它只与一个小的地理区域、一个特定的时间点或一个非常狭窄的情况相关,这些情况并不普遍适用于互联网的全局受众。为了帮助使这个问题更广泛地适用,visitthehelpcenter.关闭9年前。我有这样的类(class):classProduct{public:virtualdoublegetPrice();virtualvoidsetPrice(doubleprice);};classMusicProduct{protected:stringauthor;doubleprice;public:virtualstringgetAuthor();v

c++ - 对 B::B & B::~B 的 undefined reference

我不断收到g++编译器的投诉,说下面的代码有问题。仔细检查后,我还是想不通为什么从embedMain.cpp中找不到B类的构造函数和析构函数。谁能给我一点提示?谢谢//embedMain.cpp#include"embed.h"intmain(void){Bb("helloworld");return0;},//embed.h#ifndefEMBED_H#defineEMBED_H#includeclassB{public:B(conststd::string&_name);~B();private:std::stringname;};#endif,//embed.cpp#includ

C++ 单例 undefined reference

我是C++的新手,正在尝试理解C++中的单例模式。myclass.h#ifndefMYCLASS_H#defineMYCLASS_HclassMyclass{public:staticMyclass*getInstance();private:Myclass(){}Myclass(Myclassconst&){}Myclass&operator=(Myclassconst&){}staticMyclass*m_instance;};#endif//MYCLASS_Hmyclass.cpp#include"myclass.h"Myclass*Myclass::getInstance(){

c++ - 如何为 lambda 创建 'reference'?

我想捕获对lambda的“引用”,我认为函数指针可以解决问题,如下所示:int(*factorial)(int)=[&](intx){return(x但我得到cannotconvertfrommain::lambdatoint(_cdecl*)(int).那么指向lambda的正确方法是什么? 最佳答案 由于lambda不是无状态的,因此不能将其转换为函数指针。请改用std::function。std::functionfactorial=[&](intx){return(x 关于c++

c++ - 是否可以将编译时 "reference"赋给变量?

考虑以下代码:Matrix4x4perspective(constViewFrustum&frustum){floatl=frustum.l;floatr=frustum.r;floatb=frustum.b;floatt=frustum.t;floatn=frustum.n;floatf=frustum.f;return{{2*n/(r-l),0,(r+l)/(r-l),0},{0,2*n/(t-b),(t+b)/(t-b),0},{0,0,-((f+n)/(f-n)),-(2*n*f/(f-n))},{0,0,-1,0}};}为了提高构建矩阵的可读性,我必须从平截头体结构中复制值,

Vitis HLS出现undefined reference to的可能解决办法

问题描述:undefinedreferenceto`cv::namedWindow(std::__cxx11::basic_string,std::allocator>const&,int)'undefinedreferenceto`cv::resizeWindow(std::__cxx11::basic_string,std::allocator>const&,int,int)'undefinedreferenceto`cv::imshow(std::__cxx11::basic_string,std::allocator>const&,cv::_InputArrayconst&)'unde

C++ 对 WinMain@16 的 undefined reference (Code::Blocks)

我正在使用Code::Blocks学习C++,每次我尝试创建一个新类时,我都会收到一条错误消息:undefinedreferenceto`WinMain@16'这是我一直在使用的代码:主类#include"Lime.h"#includeusingnamespacestd;intmain(){Limelime;return0;}青柠类(.ccp):#include"Lime.h"#includeusingnamespacestd;Lime::Lime(){cout石灰header(.h):#ifndefLIME_H#defineLIME_HclassLime{public:Lime();

c++ - 提升.Python : Getting a python weak reference to a wrapped C++ object

我已经使用Boost.Python包装了一个C++类。这些对象在C++端具有强引用(boost::shared_ptr),并且在Python中也可能存在断断续续的强引用。到目前为止,一切正常。但是,如果我从其中一个强引用创建一个python弱引用,那么一旦最后一个python强引用消失,这个弱引用就会被删除。我希望弱引用一直存在,直到C++端的最后一个强引用也消失为止。有可能实现吗?换句话说:有没有办法从python中找出特定的C++对象(由Boost.Python包装)是否仍然存在? 最佳答案 您如何持有对包装类的“C++强引用”

c++ - 非类型模板参数 : how to pass reference to base class object?

似乎无法传递对的引用派生对象的基类对象作为模板参数,正如我在这里尝试做的那样:structa{int_v;constexpra():_v(0){}constexpra(intv):_v(v){}};structc:publica{constexprc():a(){}constexprc(intv):a(v){}};externconstcdefault_a;constexprconstcdefault_a{1};consta&c_as_a=default_a;//^--thisline(16)causesnoerror-ccanbeconvertedtoatemplatestructb

c++ - 警告 #13212 : Reference to ebx in function requiring stack alignment

我正在尝试使用ICC2018编译以下代码:__asm{movebx,xx;xxaddresstoregisters}其中xx是int16类型。这是我的函数中的第一条指令。我使用上面的汇编代码收到以下警告:警告#13212:在需要堆栈对齐的函数中引用ebx令人惊讶的是,当我用eax或esi替换ebx时,我看到警告消失了。我不明白为什么我只看到ebx的问题,据我所知,ebx和eax都具有相同的架构(32位寄存器)。另外,当我用ICC2013编译相同的代码时,我没有看到警告。谁能帮我解决这个警告?谢谢! 最佳答案 如果需要额外对齐,所选平