PREFACENewbie warning, please take it easy on me, I literally just picked up c++ a few days ago so any explanation you give you'll have to dumb it down to kindergarten level for me.
With that said, I'm obviously learning the very basic syntax of c++ and how things go together. I've generally had pretty good success just messing around doing my own thing and making very simple little programs. The first roadblock that hit me was separating classes into different files. I tried to write the most simple code to just test it, and it will not compile for me, even after hours of toying around with it. So I felt the need to get some advice from more seasoned coders, before I toss my sanity out the window. Now I'm using this guy's youtube video(s) as reference, he as a very good way of simplifying a lot of the concepts.
http://www.youtube.com/watch?v=NTip15BHVZcThat's the video that has separating classes into different files. I copied his code word for word, just changing variable names to my own, and while his compiles, mine does not. I would like to know why that is? I know he is using a different (older) version of codeblocks, but does that change how files are supposed to compile?
Anyway, here's the code:
main.cpp
#include <iostream>
#include "bent.h"
using namespace std;
int main()
{
bent a;
return 0;
}
bent.cpp
#include "bent.h"
#include <iostream>
using namespace std;
bent::bent()
{
cout << "testing 123" << endl;
}
bent.h
#ifndef BENT_H
#define BENT_H
class bent
{
public:
bent();
};
#endif // BENT_H
Here is the error that I get:
||=== Build: Debug in verti (compiler: GNU GCC Compiler) ===|
c:\program files (x86)\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.7.1\..\..\..\libmingw32.a(main.o):main.c:(.text.startup+0xa7)||undefined reference to `WinMain@16'|
||=== Build failed: 1 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|
Before you ask, I did use console application option, not windows application.
Now what I'm looking for really is how to change my code to make this compile and run. I get all the basic concepts this is supposed to represent so I'm good with that, but maybe a brief description of why my code doesn't work would be great, and a newbie step by step guide on how to fix it.
Thank you for your time!