[英]Understanding Watch window in VisualStudio 2010
I cannot understand what the part of the object within square bracket means ( [bsm::Material] see pic below ). 我不明白方括号内的对象部分的含义([bsm :: Material]参见下图)。 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). 我希望MaterialLayer类型的对象ml仅由Object类型的一部分(基类)+两个字段的厚度和材质(指向Material的指针)组成。
So, what is the part between square brackets, shown by Visual Studio 2010 in its Watch window? 那么,Visual Studio 2010在其“监视”窗口中显示的方括号之间是什么部分?
Here is the definition of the Material, Object, and MaterialLayer classes: 这是Material,Object和MaterialLayer类的定义:
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
};
It looks like ml
is declared as bsm::MaterialLayer*
, but a pointer of type bsm::Material*
was assigned to it by typecasting: 看起来ml
被声明为bsm::MaterialLayer*
,但是类型转换bsm::Material*
类型的指针分配给它:
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
. 这不会在编译时产生类型转换错误,但是几乎可以肯定会导致诸如thickness
和material
无意义值之类的错误。
However, since they both share a common parent, Watch shows its real child in square brackets. 但是,由于他们都有共同的父母,因此Watch在方括号中显示了其真正的孩子。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.