• Advertisement
Sign in to follow this  

Compile help

This topic is 4258 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement