0

Alirhgt, i tried to sort this one out myslef but can't. So, i have a task to build a paint program in the console, i have a set of functions dealing with the console. My task being only to connect them logically to do something useful. The problem is that everytime i #include the two files given : the .h and the .cpp file, i get the LNK2005 error that they are already defined. If i only include the header file, the functions don't do anything( i tried using one function but the console just stood there doing nothing). Can anybody tell me what i'm doing wrong? I haven't worked with C++ in a bit, so i might be doing some stupid mistake.

Bartlomiej Lewandowski
  • 10,771
  • 14
  • 44
  • 75
  • We don't have enough information. For starters, you should `#include` the .h file, *not* the .cpp file. Show us some source code and *exact* error messages, and we might be able to help. And if this is homework, please add a [tag:homework] tag. – Keith Thompson Oct 02 '11 at 16:51
  • You simply missing to link some library (because its linker error) – legion Oct 02 '11 at 16:55

1 Answers1

0

First off, you should never include cpp files.

Second, you might need include guards. Format headers like this:

#ifndef FILE_H
#define FILE_H

struct foo {
    int member;
};

#endif

You can read about why from here: http://en.wikipedia.org/wiki/Include_guard

Pubby
  • 51,882
  • 13
  • 139
  • 180