C++ Windows Form Application Help

I am working in C++ to make a program that will keep track of our hours at robotics. The idea is that you would pick you name from a list and click sign in and it would store the time you clicked and then when you left you would click sign out and it would calculate the time you had been there. I was planning on using an array to store the beginning time and another one to store the ending. I do not have that much experience in C++ (took a class last year at our high school) and have absolutely no experience in C++ form applications. I kinda know how to do this in Visual Basic but I thought C++ would be a fun challenge. How would I go about making a global array to use in my functions? I read that I would have to put it in a header file but how would I go about doing that? All help will be appreciated.

edit: I am using Visual Studio 2008. I don’t know if that matters at all.

My short answer would be to use C#. It uses C++ syntax and gives you quicker access to the form classes that you’ll want to use.

If you are positively set on using C++, then I’d get well read on MFC (yuck!) or the CLR extensions in C++ including how to write “managed code” in C++. Again, these are fairly substantial headaches that you can bypass by using C#.

Regarding your specific question about global arrays, they are generally a bad practice in C++. Also, if you don’t know just how many elements there will be, you’ll want to use a dynamic allocation type, like Vector (found in the STL header ‘vector.h’). You may want to consider having a class (with the appropriate access functions) to hold the arrays/vectors. Or have a class to describe a person who’s time you are tracking, then hold the time values there.

As a side question, have you considered how you’re going to persist the data? I assume you want to be robust against a program crash or power outage.

I guess I’ll try C# there is no particular reason that I am using C++ except to learn. I guess learning C# would be just as much of a learning C++. I really don’t know what I am doing to persist the data. never done anything like that before. if you have any advice, that’d be great.

at first thought, options could include a database(VS2008 has the ability to create a SQL server database file and automatically set up the code to connect to it) or a flat text file. I am a fan of redundancy when it seems useful(as with the power outage case), so I would suggest the database for generic storage, and a flat text file as a log(possibly in a CSV or XML format)

It may seem excessive to some people but I’m fine with that haha

Yeah, I second using C#. If you don’t have enough experience writing this thing, why don’t you try VS Lightswitch. It’s kind of like MS Access on steroids, and sounds like it might solve your problem well.

If you want to use C++, you could use a GUI library/framework like Qt or wxWidgets. These are probably much better than the mentioned Microsoft solutions, though they probably have a learning curve as well.

Python has some gui libraries as well, including python bindings for Qt and wxWidgets.

I don’t know enough about C# to suggest whether that is a better solution.

I switched to C# and it made things much simpler. I have decided to use a database to store everything and a class to keep track of all the variables. I’ll look up VS lightswitch and see what I can do with that. I was thinking python but I honestly have little to no experience with it so I’ll save that for a simpler program.