Hi all!
I've just started learning c++ (so you could call me a novice!). Anyway, I had an issue that I have now resolved. But what I'd like to know is why the error happened in the first place.
Let me explain:
I was following a tutorial for a console application. There was only one page of code named main.cpp. I hadn't created a project in Code::Blocks, I just created a new empty file, and coded away. When I compiled and ran the code, it worked just fine.
Then, as the tutorial instructed, I split the code into main.cpp and GradeBook.h. Again, after compiling and running, it worked just fine.
Then the tutorial dictated that the GradeBook.h file should be itself split into 2 parts: GradeBook.h containing the class's interface (prototypes), and GradeBook.cpp, which contained the member function definitions for the GradeBook class in the header file.
This time, however, when I compiled and ran the files it didn't work. Instead, I got the following error message: undefined reference to '_WinMain@16'.
Of course, at first I thought I had miscoded something somewhere, but after 30 minutes of thorough checking the code was fine. The next morning, I decided to create a console project and I added the same files that I had already written into the new project (without changing a single line of code!).
This time, when compliled and run, it worked just fine.
So, I haven't really understood what or why the error is/happened. Can someone explain any underlying issues, please?
Many thanks in advance,
Tony