Adding a header file?

So I have a file called main.cpp and another called Character.h, in the same folder in a DevC++ project:
1
2
3
4
5
6
//main.cpp
int main()
{

return 0;
}
1
2
3
4
5
6
//Character.h
class Character
{


}


Now when I put #include "Character.h" before int main()


It gives me an error:
2 C:\Projects\Overworld\main.cpp new types may not be defined in a return type
2 C:\Projects\Overworld\main.cpp extraneous `int' ignored
C:\Projects\Overworld\main.cpp In function `Character _mangled_main()':
5 C:\Projects\Overworld\main.cpp conversion from `int' to non-scalar type `Character' requested
C:\Projects\Overworld\Makefile.win [Build Error] [main.o] Error 1
Stop using Dev C++; it is, to be quite frank, shit.

Use MSVC++ 2008. [url]http://www.microsoft.com/express/vc/[/url]
You are missing a semi colon at the end of your class

1
2
3
4
class Character {


};


Kiana: You would get an error for this in both Dev C++ and VS....
Last edited on
Thanks for that, i didn't know classes needed semicolons. I'm new to classes in C++ though.

Personally I like DevC++ better than MSVC++, it's much simpler and easier to use for a beginner like me.
Whenever you declare a class, you can also declare objects of that class:

1
2
3
class myClass{
    int myPrivateMember;
} myClass_Instance;


That's what the semicolon's for.
Topic archived. No new replies allowed.