草庐IT

dynamic-synonym

全部标签

c++ - dynamic_cast 与动态库边界

我正在阅读“C++GUIProgrammingwithQt4”,在那里我发现了以下语句UnliketheStandardC++dynamic_cast(),Qt’sqobject_cast()workscorrectlyacrossdynamiclibraryboundaries.Qt的官方文档中也有类似的说法,网址为https://doc.qt.io/qt-5/qobject.html#qobject_cast这是什么意思?我们不能在C++中使用dynamic_cast的确切位置是什么?那么虚函数呢?将它们与动态链接库一起使用是否安全? 最佳答案

【C++入门到精通】C++类型的转换 | static_cast | reinterpret_cast | const_cast | dynamic_cast [ C++入门 ]

阅读导航引言一、强制转换(集成C语言的语法)二、static_cast操作符1.操作符介绍2.使用示例(1)基本类型之间的转换(2)类型之间的隐式转换(3)类指针和引用之间的转换三、reinterpret_cast操作符1.操作符介绍2.使用示例(1)将指针转换为整数(2)将整数转换为指针(3)将指向基类的指针转换为指向派生类的指针(4)将指向不同类型的指针进行转换四、const_cast操作符1.操作符介绍2.使用示例(1)移除常量性以修改对象的值(2)在函数中移除常量性以调用非常量版本的成员函数(3)移除常量性以进行底层操作五、dynamic_cast操作符1.操作符介绍2.使用示例(1)

c++ - C/C++ : Bitwise operators on dynamically allocated memory

在C/C++中,是否有一种简单的方法可以将按位运算符(特别是左移/右移)应用于动态分配的内存?例如,假设我这样做了:unsignedchar*bytes=newunsignedchar[3];bytes[0]=1;bytes[1]=1;bytes[2]=1;我想要一种方法来做到这一点:bytes>>=2;(那么“字节”将具有以下值):bytes[0]==0bytes[1]==64bytes[2]==64为什么值应该是这样的:分配后,字节如下所示:[00000001][00000001][00000001]但我希望将字节视为一长串位,如下所示:[000000010000000100000

c++ - auto_ptr 和 dynamic_pointer_cast

如果我想将dynamic_cast与shared_ptr一起使用,我可以使用dynamic_pointer_cast。如果我想转换auto_ptr,我该用什么?我假设如下所示。structB:A{};...auto_ptrbase(...);auto_ptrderive=dynamic_pointer_cast(base);我正在为shared_ptr使用boost 最佳答案 auto_ptrbase(...);if(B*query=dynamic_cast(base.get())){//takeownershipbase.rele

Mapless Online Detection of Dynamic Objects in 3D Lidar解读

MaplessOnlineDetectionofDynamicObjectsin3DLidar文章目录MaplessOnlineDetectionofDynamicObjectsin3DLidar前言一、摘要二、方法1.odometry2.点云比较3.freespacecheck3.箱式滤波器4.区域生长总结前言最近在做动态点滤除的work,在调研相关的文献,所以打算记录一下自己对相关文献的理解,如果有理解不到位的地方,也请大家不吝指正。一、摘要  本文提出了一种无模型、无设置(?)的三维激光雷达数据中动态物体在线检测方法。我们明确补偿了当今3D旋转激光雷达传感器的运动失真。我们的检测方法使用

c++ - 为什么 dynamic_cast 可以用于非多态类型的向上转换?

参见here:dynamic_castcanonlybeusedwithpointersandreferencestoclasses(orwithvoid*).Itspurposeistoensurethattheresultofthetypeconversionpointstoavalidcompleteobjectofthedestinationpointertype.Thisnaturallyincludespointerupcast(convertingfrompointer-to-derivedtopointer-to-base),inthesamewayasalloweda

c++ - static_cast 和 dynamic_cast 在特定场景中的不同行为

在下面的场景中,我没有弄清楚static_cast和dynamic_cast之间的真正区别:**///withstatic_cast///**classFoo{};classBar:publicFoo{public:voidfunc(){return;}};intmain(intargc,char**argv){Foo*f=newFoo;Bar*b=static_cast(f);b->func();return0;}Output:SuccessfullyBuildandCompiled!**///withdynamic_cast///**classFoo{};classBar:publ

从基础到派生的 shared_ptr 的 C++ dynamic_ptr_cast 失败

这是我本周遇到的一个益智游戏。部分原因是我在编写了一段时间的Java代码后刚刚回到C++编码。给定以下代码:classBase{};classA:Base{public:virtualvoidrun(){coutptrToA=shared_ptr(newC());cout(ptrToA)run();assert(dynamic_pointer_cast(ptrToA));cout为什么会产生如下输出?PointertoA:0x1f29c010DynamicCastAptrtoC:0Running...ThisisC.tester-cpp:tester.cpp:89:intmain(in

C++/QML : How to define and handle multiple contexts for dynamically created components?

基本上我的情况是这样的:我有一个扩展QQuickView的类,它通过设置上下文属性将某些对象从C++公开到QML。显示的View是从QML创建的,并且都是同一定制组件的不同实例;当某些事件发生时会创建新View,当这种情况发生时,现有View应显示最初在C++端分配给它们的对象,而新View应显示分配给它们的对象。所以,在C++方面,我有这样的东西:WindowManager::WindowManager(QQuickView*parent):QQuickView(parent){//Settingthesourcefiletousethis->setSource(QUrl("qrc:

C++/阿杜伊诺 : dynamic int array

我正在为Arduino编写类(class)。到目前为止一切顺利,但我现在有点卡住了...我已经在我的类中声明了一个int数组classmyClass{public:MyClass(intsize);private:int_intArray[];};当我初始化类MyClassmyClass1(5)时,我需要数组看起来像这样{0,0,0,0,0}。我的问题:我需要做什么才能使数组包含“大小”数量的零?MyClass::MyClass(intsize){//whatgoesheretodynamicallyinitializethearrayfor(inti=0;i编辑:跟进下面的各种回复,