I\'m learning C++ with Code::Blocks, and everytime i try to create a new class, I get an error message saying:
undefined reference to `WinMain@16\'
>
It looks like you're building a Windows application, rather than a console application. Therefore you need a WinMain function as the program entry point rather than a main
.
I'm not that familiar with CodeBlocks, but somewhere in the project setting there will be a setting that lets you specify the subsystem your program is running in. It's probably say "Windows", and one of the options should be "Console", so you can change it to that if you really want a console application. Judging by the fact your using cout
I suspect a console application is what you want. If it is then you can leave main
as your entry point.
You can also opt for a console application when you create a new project. This screenshot and text should help.
NOTE: I've just checked some more, and in the Project/target option
you can go to the "Build targets" tab and see the subsystem you're building for. It's called "Type" on the tab, and one of the dropdown options will be "Console application".