了解VisualStudio 2010中的Watch窗口 [英] Understanding Watch window in VisualStudio 2010
问题描述
我不明白方括号内的对象部分是什么意思([bsm :: Material]见下图)。我希望类型MaterialLayer的对象ml只能由Object(基类)+两个字段的厚度和材质(指向Material)的一部分组成。
I cannot understand what the part of the object within square bracket means ( [bsm::Material] see pic below ). I would expect the object ml of type MaterialLayer to be composed only of a part of type Object (base class) + two fields thickness and material (a pointer to Material).
那么,Visual Studio 2010在其监视窗口中显示的方括号之间的部分是什么?
So, what is the part between square brackets, shown by Visual Studio 2010 in its Watch window?
以下是Material,Object和MaterialLayer类的定义:
Here is the definition of the Material, Object, and MaterialLayer classes:
class Object
{
public:
// Methods
};
class Material : public Object
{
int type;
std::string name;
std::vector<Property *> properties;
public:
// Methods
};
class MaterialLayer : public Object
{
double thickness;
Material * material;
public:
// Methods
};
推荐答案
看起来像 ml
被声明为 bsm :: MaterialLayer *
,但是类型为 bsm :: Material *
通过类型转换分配给它:
It looks like ml
is declared as bsm::MaterialLayer*
, but a pointer of type bsm::Material*
was assigned to it by typecasting:
bsm::MaterialLayer *ml;
bsm::Material *foo;
ml = (bsm::MaterialLayer *)foo;
这不会在编译时产生类型转换错误,但几乎肯定会导致错误,如废话值在厚度
和材料
。
This does not generate a typecast error in compile-time but will almost certainly lead to errors like nonsense values in thickness
and material
.
然而,由于他们两人分享一个共同的父母,Watch在方括号中显示其真正的孩子。
However, since they both share a common parent, Watch shows its real child in square brackets.
这篇关于了解VisualStudio 2010中的Watch窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!