私有成员初始化失败 [英] private member initialization fail

查看:83
本文介绍了私有成员初始化失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我有一个基本但严峻的问题,请原谅我要解决的基本问题,但我无法提出解决方案.
使用VisualC ++ 2003,我创建了一个基于MFC架构(在win XP pro sp3下运行)的SDI图形桌面应用程序,用于数据可视化.

各种私有成员用于正确缩放和抵消要在视图中显示的数学函数和数值生成的数据,并跟踪可视化参数.它们在.h文件的appView类的private节中声明,并在.cpp的类构造函数(只有一个)中初始化.他们中的许多人都没有被相继覆盖.问题在于它们已被正确读取和使用,但是监视窗口,智能感知和即时命令窗口未将它们检测为已初始化,并且无法显示正确的窗口,并显示奇怪的"值.此外,当我将它们分配给局部变量时,局部变量会采用正确的值,但是如果我尝试直接在同一函数中对其进行修改,则会继续显示它们错误.
我没有警告或错误

示例:

.int m_YLPrecision \\要在左y轴上显示的有效位数,在CView.h中声明为私有,并在构造函数中设置为2.

使用该轴时,正确显示2位数字.

当用intellisense进行检查或在调试中观看时,它显示不正确(且随机)的值:到现在为705.(第一次使用该变量时,它始终显示-842150451.调试在构造函数中初始化行的步骤继续显示赋值后相同的值!)

.m_YLPrecision ++/-正常工作:轴显示3/1位数字,但是智能/观察视图继续显示错误和unmodified(!!)值(在此示例中,它继续显示705)

进行分配:int test = m_YLPrecision,
测试变量显示正确的值!
相同的行为代表所有私有成员.
我在哪里错了?我有0个主意.
这是我的错误(我猜想),项目的错误配置,VS2003问题吗?
我可以使用类成员,但是由于必须引入许多本地测试变量,因此几乎不可能调试应用程序.

在此先感谢

Hi to all,

I have an elementary but severe problem, and excuse myself for the basic question, but I can''t argue a solution.
Using VisualC++ 2003 I created a SDI graphic desktop app, based on MFC architecture (running under win XP pro sp3) for data visualization purposes.

Various private members are used to correctly scale and offset math funtions and numerical generated data to be shown in the View, and to keep track of visualization parameters. They are declared in the private section of the appView class, in the .h file, and are initializated in the class costructor (there is only one) in .cpp. Many of them are not successively overwritten. The problem is that they are correctly read and used, but watch window, intellisense and instant commmand window don''t detect them as initializated and fail to show correct window, showing "strange" values. Beside, when I assign them to a local variable, the local variable assumes the correct value, but if I try to modify them directly in the same function, they continue to be shown wrong.
I have no warnings or errors

Example:

.int m_YLPrecision \\the number of significtive digits to be shown on the left y axis, declared as private in CView.h and set to 2 in the costructor.

.When used, the axis shows correctly 2 digits.

.When inspected with intellisense or watch in debug, it shows incorrect (and random) values: by now 705. (the first time the variable is used, it always shows -842150451. debug stepping the initialization line in the costructor keeps on showing the same value after the assignation!)

.m_YLPrecision++/-- works correctly: the axis shows 3/1 digits, but intellisense/watch view keeps on showing the incorrect and unmodified(!!) value (in this examples, it keeps on showing 705)

.Making the assignation : int test = m_YLPrecision,
the test variable shows the correct value!!!!!!!!

The same behaviour stands for ALL private members.
Where am I wrong?? I have 0 ideas.
Is it an error of mine (as I suppose), a misconfiguration of the project, a VS2003 issue??
I can use the class members yet, but debugging the app is nearly impossible because of the many local test variables I have to introduce.

Thanks in advance

推荐答案

您是否正在使用调试版本?
 
Are you using a debug build?
 


斯蒂芬,谢谢!
是的,我正在使用它,但是直到两周前,它在调试版本中都可以正常工作.
从那时起,我进行了各种代码更改,这些更改仅影响数学"功能,而不影响与文档/视图体系结构相关的功能,但是我无法确定何时/为什么开始这种行为,因为该应用程序本身可以正常工作(并且目前可以正常工作) ) 好吧!
除了使用其他版本外,实际上还很困难,因为该应用程序不是从头开始"创建的,但是它是对以前版本的重大改版,具有各种版本配置,但没有任何作用.. !!
Hi Stephen, thanks!
Yes, I''m using it, but until two weeks ago it worked perfectly with debug build.
I made various code changes since then that affected only the "mathematical" functions, not the Document/View architecture related ones, but I can''t say with confidence when/why this behaviour started, because the app itself worked (and currently works) well!
Beside using other builds is actually really difficult, because the app has not been created "from scratch", but it is a big restyling of a previous version, with various build configurations, but none working..!!


这篇关于私有成员初始化失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆