Link to home
Start Free TrialLog in
Avatar of alzzz
alzzz

asked on

Function already defined Error, Visual C++

hey,

I'm trying to create a GUI in Visual Studio, but when i run through that piece of code but i get the errors:


Error      1      error LNK2005: "public: void __clrcall Input::Score0(void)" (?Score0@Input@@$$FQAMXXZ) already defined in cricket_i1_v00.obj      Input.obj      cricket_i1_v00

Error      3      fatal error LNK1169: one or more multiply defined symbols found      C:\Documents and Settings\hlepretre\MyC++Codes\cricket_i1_v00\Debug\cricket_i1_v00.exe      1      cricket_i1_v00



My code is:

Input.cpp


class Input
{
public:
      int RunsScored[11];
      void Score0();
};
void Input::Score0()
{
      RunsScored[0]=1;
}


in the main function i reference it this way:

#include "Input.cpp"

and call it this way

Input ins;
ins.Score0();
this->txtB->Text = ins.RunsScored[0].ToString();


Do you have an idea of where the error comes from?

Thanks
Avatar of alzzz
alzzz

ASKER

thanking you
ASKER CERTIFIED SOLUTION
Avatar of Infinity08
Infinity08
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of alzzz

ASKER

thanks to you both