什么时候应该使用 static_cast、dynamic_cast、const_cast和reinterpret_cast?
作者:e.James 提问时间:12/2/2008
什么是正确的用途: static_cast dynamic_cast const_cast reinterpret_cast (type)value(C 样式强制转换) type(value) (函...
针 问答列表
作者:e.James 提问时间:12/2/2008
什么是正确的用途: static_cast dynamic_cast const_cast reinterpret_cast (type)value(C 样式强制转换) type(value) (函...
作者:BENG 提问时间:8/29/2023
我正在开发 C++/OpenGL 3D 网格建模软件。基本上是一个非常原始的搅拌机。 A 包含顶点缓存(下面的类),其顶点数据存储在单个块中以发送到 glBufferData。这就是下面的向量。然后...
作者: 提问时间:7/17/2009
我总是搞砸如何使用 、 和正确。有没有一套规则来定义你能做什么和不能做什么?const int*const int * constint const * 我想知道在分配、传递给函数等方面的所有注意事...
作者:peks 提问时间:8/31/2023
请有人能向我解释一下这种奇怪的指针行为吗?我错过了什么吗?!? 开始第一次尝试 int *foo=(int*)malloc(sizeof(int)*4);//allocates memory fo...
作者:comediann 提问时间:8/27/2023
我创建了一个具有一些类属性的类书,例如名称和作者(没有动态分配),然后我创建了一个包含动态书数组(如 book* set)及其大小和一些方法的类库,因此在库类中,我向析构函数添加了一个“delete”...
作者:Albert Wang 提问时间:9/4/2023
#include <iostream> using namespace std; int main() { int i = 5; double d = 0.5; const string ...
作者:Leodero20 提问时间:8/16/2023
我是 LeetCode 的新手,我唯一的 C 语言背景是它的一门基础知识。我希望改进和学习更多。我认为我在这里的问题出在指针或 malloc 上。我该如何解决这个问题? 这是我的代码: /** ...
作者:user12645705 提问时间:9/4/2023
#include <stdio.h> #include <stdlib.h> #include <string.h> #include "splitter.h" #define FOUR_K 40...
作者:RobertC 提问时间:9/5/2023
我在 C 方面非常基础,我不理解这些代码中的某些内容。在第一段代码中,我声明了一个名为 arr 的数组,其中包含预定义的值,并且我还声明了一个名为 p 的 int 类型的指针。之后,我指向 arr 的...
作者:pushpa 提问时间:9/5/2023
这个问题在这里已经有答案了: 如何破译C语言中的复杂指针声明? (4 个答案) 3个月前关闭。 假设我有 和void (*ptr[3])(int)void (*ptr)[3](int) 第一个按预...