Where to define global variables?

Hi guys, I'm fairly new to VC++ and I'm having a hard time understanding which locations the IDE has set up for me to define global variables.

I have been defining my variables under this section in Form1.h(64-69):

1
2
3
4
5
6
private:
		/// <summary>
		/// Required designer variable.
		/// </summary>

		int x,y;


but then initializing them a lot earlier in Form1.h(25-32):

1
2
3
4
5
6
7
8
9
public:
		Form1(void)
		{
			InitializeComponent();
			//
			//TODO: Add the constructor code here
			//
			y = 65;
			x = 140;



Is this correct? Is there somewhere else they should be? Maybe not even in this file?

Again, same with my methods, where should they be placed properly to be organised correctly.

I'm aware that in terms of functionality it makes little difference, the program works fine, I'm just wondering where they are meant to go?

Thanks
Last edited on
I think you didn't created yor project correctly.

Yoshould not use .net framework for C++.
I didn't know I was using .NET?

I'm using VS2005.

Care to elaborate?
Alias NeO, you've possibly selected "Windows Forms Application" from the New Project settings which by default will create a .Net based project.

You can avoid this by selecting Win32 Project.

AJM.
You declare your global variables in a separate header file, or if your program has only one .cpp file, outside of any functions.

By the way, some members of the forum hate global variables. Just saying.

-Albatross
Topic archived. No new replies allowed.