Click here to Skip to main content
15,895,142 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: ZModem Pin
Gary R. Wheeler2-Jan-04 14:22
Gary R. Wheeler2-Jan-04 14:22 
QuestiondcPrint???? Pin
JKohm1-Jan-04 15:22
JKohm1-Jan-04 15:22 
AnswerRe: dcPrint???? Pin
dan o2-Jan-04 5:14
dan o2-Jan-04 5:14 
QuestionIP Address? Pin
Dov Sherman1-Jan-04 14:07
Dov Sherman1-Jan-04 14:07 
AnswerRe: IP Address? Pin
David Crow1-Jan-04 16:06
David Crow1-Jan-04 16:06 
GeneralRe: IP Address? Pin
Dov Sherman1-Jan-04 23:43
Dov Sherman1-Jan-04 23:43 
GeneralRe: IP Address? Pin
David Crow5-Jan-04 2:11
David Crow5-Jan-04 2:11 
GeneralC++ altering the wrong class members Pin
metcarob1-Jan-04 12:25
metcarob1-Jan-04 12:25 
What exactly does the line:
rGfxOptionsWnd* m_pGfxOptionsWnd;
do?

I have chased this bug and narrowed it down to something that I believe should not happen and I don’t even know what could possibly cause it to happen.

My basic application structure is simple.

An Application Class,
An App Class derived from the Application Class

The application class has a member varible which is a Paramater class

e.g.
Application {

Public:
Param_class m_Params;

};

In it’s constructor Application instalises m_Params values.
<code> m_Params.Window.bWindowed = false;
m_Params.Window.width = 500;
m_Params.Window.height = 500;
m_Params.Window.icon = NULL;
m_Params.Window.title = "rDirectXApp Default Window Title";
m_Params.Window.wnd_type = RJM_WNDT2;
m_Params.Window.res_x = 0;
m_Params.Window.res_y = 0;
m_Params.Window.esc_to_quit = true;</code>
In it’s Constructor, App (Derived from Application) then alters some of the values as nessecary.

<code> m_Params.Window.icon = (const char *) IDI_ICON1;
m_Params.Window.title = "Super Game in this window!!!";
m_Params.Window.bWindowed = true;

m_Params.Window.wnd_type = RJM_WNDT5;
m_Params.Window.width = 600;
m_Params.Window.height = 300;
m_Params.Window.bWindowed = true;
m_Params.Window.res_x = 100;
m_Params.Window.res_y = 100;</code>
Now I can compile and run this code perfectly. I have set break points on each line shown here and I can watch the values as they go through this process and change.

I have another completely empty class, just an empty constructor and destructor.
RGfxOptions. I add the following line into Applications private section:

rGfxOptionsWnd* m_pGfxOptionsWnd;

With this line in the program I run the debug version of the program.

The Application constructor sets up m_Param exactly as it’s supposed to.

Control then passes to App’s constructor.
When: m_Params.Window.icon = (const char *) IDI_ICON1;
executes, m_Param.Height changes (nothing else)

when m_Params.Window.title = "Super Game in this window!!!";
executes, m_Params.title changes but the new value is corrupt

when m_Params.Window.bWindowed = true;
executes, nothing in m_Params alters

when m_Params.Window.wnd_type = RJM_WNDT5;
executes, nothing

when m_Params.Window.width = 600;
executes bWindowed alters

when m_Params.Window.height = 300;
executes, width alters

when m_Params.Window.bWindowed = true;
executes, nothing

when m_Params.Window.res_x = 100;
executes, wndtype alters but to an invalid value

and after m_Params.Window.res_y = 100;
the program crashes because of the invalid data.

But with the line:
rGfxOptionsWnd* m_pGfxOptionsWnd;
remmed out it all works perfectly.

Can anyone help? What does that line do? How is it possible that the statement altering the height actually alters the width member variables? I havn’t used or refered to m_pGrgOptionsWnd anywhere at all in my code. How can simply adding a pointer member varible to my class have this effect?

Thanks in advance for any suggestions. I have absoultly no ideas at the moment at all!


---
Posted By Robert Metcalf
GeneralRe: C++ altering the wrong class members Pin
Roger Allen1-Jan-04 23:37
Roger Allen1-Jan-04 23:37 
GeneralXML parser suggestion. Pin
Janovetz1-Jan-04 7:12
Janovetz1-Jan-04 7:12 
GeneralRe: XML parser suggestion. Pin
Nemanja Trifunovic1-Jan-04 14:21
Nemanja Trifunovic1-Jan-04 14:21 
GeneralRe: XML parser suggestion. Pin
Garth J Lancaster1-Jan-04 14:32
professionalGarth J Lancaster1-Jan-04 14:32 
GeneralRe: XML parser suggestion. Pin
Neville Franks1-Jan-04 22:21
Neville Franks1-Jan-04 22:21 
Generalc++ dependencies Pin
tucolino1-Jan-04 6:57
tucolino1-Jan-04 6:57 
GeneralRe: c++ dependencies Pin
Chris Richardson1-Jan-04 15:44
Chris Richardson1-Jan-04 15:44 
GeneralOpen image from file and display it Pin
DaFrawg1-Jan-04 6:10
DaFrawg1-Jan-04 6:10 
GeneralRe: Open image from file and display it Pin
Hauptman(n)1-Jan-04 6:18
Hauptman(n)1-Jan-04 6:18 
GeneralRe: Open image from file and display it Pin
DaFrawg2-Jan-04 4:33
DaFrawg2-Jan-04 4:33 
Generalfirewall project Pin
gildan20201-Jan-04 2:23
gildan20201-Jan-04 2:23 
GeneralRe: firewall project Pin
valikac1-Jan-04 5:44
valikac1-Jan-04 5:44 
GeneralRe: firewall project Pin
gildan20201-Jan-04 6:12
gildan20201-Jan-04 6:12 
GeneralRe: firewall project Pin
Hauptman(n)1-Jan-04 6:14
Hauptman(n)1-Jan-04 6:14 
GeneralRe: firewall project Pin
gildan20201-Jan-04 6:50
gildan20201-Jan-04 6:50 
GeneralRe: firewall project Pin
Hauptman(n)1-Jan-04 7:53
Hauptman(n)1-Jan-04 7:53 
GeneralMigrating processes Pin
zichun31-Dec-03 23:21
zichun31-Dec-03 23:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.