error LNK2005: need help !

This is a discussion on error LNK2005: need help ! within the C++ Programming forums, part of the General Programming Boards category; An error is prompt while compiling.. "error LNK2005: "class Controller input" (?input@@3VController@@A) already defined in Controller.obj" Code: // Class Control.cpp ...

  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 wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,333
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

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, 08: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, 06:32 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21