开发者

#include, error LNK2005

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开发者_Go百科 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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜