Thread: error LNK2005: need help !

  1. #1
    Registered User
    Join Date
    Oct 2012
    Posts
    5

    error LNK2005: need help !

    An error is prompt while compiling..

    "error LNK2005: "class Controller input" (?input@@3VController@@A) already defined in Controller.obj"
    Code:
    // Class Control.cpp //
    
    void Control::Controlling(void)
    {
          inputs = 0;
          Controller input;
    }
    
    // Controller.cpp //
    
    #define Controller
    
    class Controller
    {
      public:
          Controller(void);
          ~Controller(void);        
    }input;
    I am trying to call the input from class Controller in the function of class Control. Does my understanding for the programming was wrong?

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,656
    Where is your real code?

    Because this
    Code:
    #define Controller
     
    class Controller
    {
      public:
          Controller(void);
          ~Controller(void);       
    }input;
    Reduces to this nonsense
    Code:
    class
    {
      public:
          (void);
          ~(void);
    }input;
    > "error LNK2005: "class Controller input" (?input@@3VController@@A) already defined in Controller.obj"
    Already defined errors typically mean that you have code in a .h file, and you have included that .h file in multiple .cpp files.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need Help With LNK2005 Error
    By LyTning94 in forum C++ Programming
    Replies: 9
    Last Post: 07-13-2011, 12:56 PM
  2. LNK2005 Linker Error
    By Jonnster in forum Windows Programming
    Replies: 1
    Last Post: 03-29-2011, 08:52 AM
  3. error LNK2005:_**** already defined in main.obj
    By DenJansen in forum C Programming
    Replies: 6
    Last Post: 12-13-2010, 09:44 PM
  4. LNK2005 error (multiple declarations?)
    By maxsthekat in forum C++ Programming
    Replies: 3
    Last Post: 09-10-2009, 04:35 PM
  5. error LNK2005: _DllMain@12 already defined in SPLibrSync.obj
    By dattaforit in forum C++ Programming
    Replies: 7
    Last Post: 11-23-2006, 07:32 AM