小编Llo*_*ond的帖子

Windbg型铸造

我想在命令窗口中输入一个子类的对象到WinDbg中的父类.

示例类

class parent
{
public:
    int a;
    int b;
    parent(){ a = 10; b = 10; }
    parent(int c) : a(a){}
};

class child : public parent
{
public:
    int a;
    int b;
    child(){ a = 20; b = 20; }
    child(int d) : b(d){}
};
Run Code Online (Sandbox Code Playgroud)

我正在使用Windbg,我正在阅读帮助文件.它在C++ Numbers和Operators下显示我可以从WinDbg命令窗口执行以下类型转换:

dynamic_cast <type>(Value) 
static_cast <type>(Value) 
reinterpret_cast <type>(Value) 
const_cast <type>(Value)
(type) Value
Run Code Online (Sandbox Code Playgroud)

所以我输入Windbg命令窗口:

?? (type) Value
Run Code Online (Sandbox Code Playgroud)

有效的是

?? (char)a
?? static_cast<char>(a)
Run Code Online (Sandbox Code Playgroud)

其中a是int.

什么不起作用

?? (parent)chld
?? static_cast<parent>(chld)
?? static_cast<mod!parent>(chld)
Run Code Online (Sandbox Code Playgroud)

其中chld …

c++ windbg

3
推荐指数
1
解决办法
2154
查看次数

标签 统计

c++ ×1

windbg ×1