Skip to main content
gamedev.net
🔒 Locked

(Re?)Initialising Objects

Started by Bagpuss Dec 6, 2001 at 7:10 AM 1 replies 300+ views
Original Post
Bagpuss
Bagpuss
OK, let me start off by apologising if this is a simple question, I am self taught, and am sure I have a load of bad habits and do not know some simple stuff. Question 1 ----------- I have an SDI application (using MS Vis Studio 6). The view class has a global object in it, and it calls the constructor for the object in the correct manner. I actually now want to only create this object when someone enters in parameters into a dialogue box which is called off a menu. The View catches and displays the dialog box, and also recieves the correct parameters to create the object. (Actually just 2 integers) When I then call myobject Test(a,b); I would expect the object test to be created using the a & b parameters. When I try to compile this, I get a load of errors complaining about not being able to find object test. This is probably simple, so don''t flame me, but do I need the function that creates Test to be above the rest of the code (if you ask why didn''t I try this, it is because I just thought of that question), so it knows that there will be an object called test ? Question 2 ----------- Same application, in a different function. I have some code as follows... Test.Generate(); Invalidate(); When I run this in debug, with a break on the Test.Generate() line, the code runs fine. I can Continue after the break and the routine draws the correct output on the screen. If I am in run however, then there is no output on screen. Anyone got any ideas or suggestions ? Thanks for your help & Patience, Bp.
Shannon Barber
Shannon Barber
Post the exact error - it may be that you haven''t included the required header file...

Stuff that''s "global" to the view class(es) belong(s) in the Document object.

What _do you mean by a class with a global object? a static pointer?

Magmai Kai Holmlor
- Not For Rent
The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
Bagpuss
Bagpuss
OK, I got home, and from question 1 here are the errors..

e:\VISUAL STUDIO\COMM\MSDEV98\MYPROJECTS\Maze\MazeView.cpp(124) : error C2065: ''TestMaze'' : undeclared identifier
e:\VISUAL STUDIO\COMM\MSDEV98\MYPROJECTS\Maze\MazeView.cpp(124) : error C2228: left of ''.GetHeight'' must have class/struct/union type
e:\VISUAL STUDIO\COMM\MSDEV98\MYPROJECTS\Maze\MazeView.cpp(125) : error C2228: left of ''.GetWidth'' must have class/struct/union type
e:\VISUAL STUDIO\COMM\MSDEV98\MYPROJECTS\Maze\MazeView.cpp(138) : error C2228: left of ''.GetMapCell'' must have class/struct/union type

What I want to do is to create a new maze class when the correct parameters are entered from a dialog box, but if I make the class a member of the document as opposed to the view class, how do I call the Invalidate() function as the draw and invalidate code are in 2 seperate classes.

TIA,

Bp.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.