Background: I learned old-school c++ programming techniques, being able to declare global variables before the main() routine.

However, in Vis C++, I am having trouble, especially with global arrays. I am programming a Windows Forms application. In it, I declare a global integer array just after all my includes in the top of form1.h. Next, the contents of the array are modified during a button-click event function.

The problem: inside another button-click event function, the same global array's contents are scrambled, containing random numbers. I've experimented with using "public:" in the declarations, to no avail.

Any suggestions would be greatly appreciated. Thanks!

Recommended Answers

All 2 Replies

Any code would be greatly appreciated.

funny, the phenomenon that happens when you ask for help... all the sudden the anwer becomes obvious. Well, after printing the arrays to a file, the data proved to be correct. So, it turns out that my code is working, but for some goofy reason, the watches for these arrays aren't. After a breakpoint in the function where I print the correct global array data to a file, the watches still show erroneous data for these global arrays. Since I assumed watches don't lie, it let me on a 5-day rabbit chase. I've used watches in other software, never having trouble. Anyone else run into faulty watches? OK, I'll try to copy some code to the thread.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.