Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

transfering nonstatic info from forms to .cpp

Status
Not open for further replies.

kathy32181

Programmer
May 4, 2005
1
US
For reference to code and errors: The form and class are both called TestForm, the .cpp is called MyPong, and the project is called PongRedo.)I'm making a simple 2d game, and at one point I use a form for the user to pick something from a list of choices. The problem is that once the user makes a choice, I don't know how to get the info back to my .cpp. When I make a global variable from the form header or when I make a global variable in another header and import that to the form header, I get error LNK2005 that the variable is already defined in MyPong.obj. I do not get this error from globals in my other headers. Anyway, I tried a couple other routes, and now I'm just trying to assign each choice on the form a number and set the Tag to that number. I think that's ok, but when I try to get the tag number in the .cpp, I get an error. I've tried:

int x = ([TestForm]::Tag::get());

but then it gets mad and says: illegal call of non-static member function
I also tried just getting an int directly from the .cpp with:

(assuming that int k is defined in the form header)
int x = ([TestForm]::k;

I've also tried:

int x = TestForm.linkLabel1.Tag.get();

and I got the following errors ):

error C2275: 'pongredo::TestForm' : illegal use of this type as an expression
error C2228: left of '.Tag' must have class/struct/union
error C2228: left of '.get' must have class/struct/union

I would be happy to be able to read in the tag OR to be able to reference a non-static variable in my .cpp from TestForm.h, I can from my other header files, just not this one.

Any help on this one would be greatly appreciated!

Kate



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top