从不同的地方访问类方法时,类成员的位置会更改

时间:2022-09-25 14:47:51

I am having a problem of the location of a class member changes depending on when a function is run.

我遇到类成员位置更改的问题,具体取决于函数运行的时间。

When the constructor is running, the location of a member is 0x008bc044. Then later a member function is called and the location of the same member is still 0x008bc044. Even later on the member function is run again but the location of the same member changes to 0x008bc048. All other members of the class don't change there location. I am not casting the class to another type.

构造函数运行时,成员的位置是0x008bc044。然后调用成员函数,同一成员的位置仍为0x008bc044。即使稍后会再次运行成员函数,但同一成员的位置也会更改为0x008bc048。班上的所有其他成员都不会改变那里的位置。我没有将类转换为其他类型。

This is causing a problem because the function is now reading random data and causing incorrect output.

这导致了一个问题,因为该功能现在正在读取随机数据并导致输出错误。

I am using Visual Studio 2012, 11.0.60315.01 Update 2.

我正在使用Visual Studio 2012,11.0.60315.01 Update 2。

Album of visual studio debugger

视觉工作室调试器的专辑

1 个解决方案

#1


1  

You are running a 32 bit system, have a a derived class and show the pointer of the base class and the pointer of the derived class. In addition you have a reinterpret or c-style cast.

您正在运行32位系统,具有派生类并显示基类的指针和派生类的指针。此外,你有一个重新解释或c风格的演员阵容。

#1


1  

You are running a 32 bit system, have a a derived class and show the pointer of the base class and the pointer of the derived class. In addition you have a reinterpret or c-style cast.

您正在运行32位系统,具有派生类并显示基类的指针和派生类的指针。此外,你有一个重新解释或c风格的演员阵容。