Compile help

Started by
3 comments, last by Unconquerable 17 years, 9 months ago
Ok. I have main.cpp and two.cpp. Main has #include "two.cpp".Two has function declerations. When i try and compile i get a whole bunch of errors that look like this: multiple definition of `Player::Player()' first defined here Any help would be appreciated, thanks.
Advertisement
Where's your class declared?
Generally, it's considered a Good Thing(TM) to declare a class in a header file, with the functions in a corresponding cpp file. Then, include said header file from your main cpp file.
I generally see multiple declaration errors when a class is defined two or more times. I suggest using preprocessor commands to make it only include once.
____________________________________Spazuh- Because I've had too much coffee
Its declared once in Two.cpp
Don't #include .cpp files. You get a seperate copy of all the code when your compiler compiles the including cpp file and the included cpp file.

You put class declarations in header files, and include them.

You also put any externs, function signature and enums in the header file, should that be required.
fixed, thanks.

This topic is closed to new replies.

Advertisement