jjzjj

destructors

全部标签

swift - 无法为类型 'sqlite3_destructor_type' 调用初始值设定项

到目前为止answerfromMartinR已经完美地工作了。但是从Swift2开始,它现在会引发错误Cannotinvokeinitializerfortype'sqlite3_destructor_type'withanargumentlistoftype'(COpaquePointer)'在那些行中:privateletSQLITE_STATIC=sqlite3_destructor_type(COpaquePointer(bitPattern:0))//https://stackoverflow.com/a/26884081/1271826privateletSQLITE_TR

c++ - 类 : handling copy constructor and destructor (C++) 内的 vector

以“big3”(构造函数、复制构造函数、析构函数)的简单类:#includeusingnamespacestd;//actuallygoesintheCfilethatlinkstothisheaderfile...classplanets(){//storesmassandradiidataforplanetsinasolarsystem.public:vectormass;vectorradius;//constructorplanets(intnumObj){for(inti=0;imass(p.mass);//copyvectorsintonewclass.vectorradi

c++ - ARM C++ ABI : Constructor/destructor return values

我一直在阅读Clang源代码,并发现了一些关于ARMC++ABI的有趣之处,我似乎无法理解其理由。来自ARMABIdocumentation的在线版本:ThisABIrequiresC1andC2constructorstoreturnthis(insteadofbeingvoidfunctions)sothataC3constructorcantailcalltheC1constructorandtheC1constructorcantailcallC2.(对于非虚拟析构函数也是如此)我不确定C1、C2和C3在这里引用什么...本节旨在修改来自通用(即安腾)ABI的第3.1.5节,但

C++ "Virtual functions but no virtual destructors"

我有一个基类Media和几个派生类,即DVD、Book等...基类写成:classMedia{private:intid;stringtitle;intyear;public:Media(){id=year=0;title="";}Media(int_id,string_title,int_year):id(_id),title(_title),year(_year){}//virtual~Media()=0;voidchangeID(intnewID){id=newID;}virtualvoidprint(ostream&out);};问题是:没有析构函数,GCC给了我一堆警告cla

c++ - 根据定义,放置 "virtual destructor inside an interface"是否不再是接口(interface)?

这就是我所在的盒子。我想了解为什么在你的接口(interface)类中有一个“虚拟析构函数”很重要。如果你能坚持到最后,你就会明白为什么这些东西是用引号引起来的……我也想让所有的词汇都绝对正确。到目前为止,我的流程如下:有时你有基类,有时你有继承自基类的派生类。如果您有一个发现自己指向派生对象的基指针,并且您希望从该基指针指向派生对象进行的成员函数调用表现为如果它实际上是从派生对象调用的,那么你调用的成员函数最好在基类中声明为virtual。接口(interface)是任何具有仅纯虚函数的类。如果从这个接口(interface)类派生出一个新的类,并且实现了所有的纯虚函数,那么最终就可

c++ - 如何处理clang中的 "exit-time destructor"警告?

在我的C++11代码中,我在以下情况下收到clang警告“声明需要退出时析构函数”:staticconststd::mapmymap={{1,{"A","B","C"}},{2,{"D","E","F"}}};据我了解,Google需要一个“退出时析构函数”以确定性的方式销毁main()和静态变量,以防止由于“已发布的变量”而导致退出时崩溃。那正确吗?有人能解释得更好吗?另外:我能做些什么(我不想禁用警告)?上面的代码只在一个线程的上下文中使用。看起来这就是Chromium处理这些情况的方式;这也是我的情况的正确方法吗?#defineCR_DEFINE_STATIC_LOCAL(typ

c++ - 跳出 block : do destructors get called?

考虑以下代码:voidfoo(){{CSomeClassbar;//Somecodehere...gotolabel;//andhere...}label://andhere...}会调用bar的析构函数吗? 最佳答案 C++标准说:Onexitfromascope(howeveraccomplished),destructors(12.4)arecalledforallconstructedobjectswithautomaticstorageduration(3.7.2)(namedobjectsortemporaries)th

c++ - GNU 编译器警告 "class has virtual functions but non-virtual destructor"

我在C++中定义了一个接口(interface),即一个只包含纯虚函数的类。我想明确禁止接口(interface)的用户通过指向接口(interface)的指针删除对象,所以我为接口(interface)声明了一个protected非虚拟析构函数,类似于:classITest{public:virtualvoiddoSomething()=0;protected:~ITest(){}};voidsomeFunction(ITest*test){test->doSomething();//ok//deletingobjectisnotallowed//deletetest;}GNU编译器

c++ - 在 C++ 编译期间出现 'has virtual method ... but non-virtual destructor' 警告是什么意思?

#includeusingnamespacestd;classCPolygon{protected:intwidth,height;public:virtualintarea(){return(0);}};classCRectangle:publicCPolygon{public:intarea(){return(width*height);}};有编译警告Class'[C@1a9e0f7'hasvirtualmethod'area'butnon-virtualdestructor如何理解这个警告以及如何改进代码?[EDIT]这个版本现在正确吗?(试图给出答案以阐明自己的概念)#inc

c++ - 在 C++ 编译期间出现 'has virtual method ... but non-virtual destructor' 警告是什么意思?

#includeusingnamespacestd;classCPolygon{protected:intwidth,height;public:virtualintarea(){return(0);}};classCRectangle:publicCPolygon{public:intarea(){return(width*height);}};有编译警告Class'[C@1a9e0f7'hasvirtualmethod'area'butnon-virtualdestructor如何理解这个警告以及如何改进代码?[EDIT]这个版本现在正确吗?(试图给出答案以阐明自己的概念)#inc