Click here to Skip to main content
15,902,892 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Question about run at start up Pin
Anonymous15-Jun-03 0:33
Anonymous15-Jun-03 0:33 
GeneralRe: Question about run at start up Pin
Ryan Binns15-Jun-03 3:01
Ryan Binns15-Jun-03 3:01 
GeneralRe: Question about run at start up Pin
Mazdak15-Jun-03 7:20
Mazdak15-Jun-03 7:20 
GeneralRe: Question about run at start up Pin
Ryan Binns15-Jun-03 14:52
Ryan Binns15-Jun-03 14:52 
GeneralRe: Question about run at start up Pin
Mazdak15-Jun-03 20:56
Mazdak15-Jun-03 20:56 
Questionhow to toggle desktop Pin
jerryage14-Jun-03 15:38
jerryage14-Jun-03 15:38 
GeneralCGridCtrl Add & Delete UI Pin
Sam Hobbs14-Jun-03 14:29
Sam Hobbs14-Jun-03 14:29 
QuestionDeclaring Class function error? Pin
Aidman14-Jun-03 13:37
Aidman14-Jun-03 13:37 
Hi all, Smile | :)

I am experiencing a strange problem when declaring classes outside the main source file in VC++. I have made an experiment that demonstrates my problem. There are two files: “main.cpp” and “class.cpp”.

“main.cpp” content:
#include "class.cpp"

int main() {
	return 0;
}

“class.cpp” content:
class Class {
public:
	void Test();
};

void Class::Test() {
	return;
}

When I try to compile I get following error:
<br />
--------------------Configuration: main - Win32 Debug--------------------<br />
Compiling...<br />
main.cpp<br />
class.cpp<br />
Linking...<br />
class.obj : error LNK2005: "public: void __thiscall Class::Test(void)" (?Test@Class@@QAEXXZ) already defined in main.obj<br />
Debug/main.exe : fatal error LNK1169: one or more multiply defined symbols found<br />
Error executing link.exe.<br />
<br />
main.exe - 2 error(s), 0 warning(s)<br />

It says that the function void Test() is already declared, but how? Please help me, am I doing something wrong? Frown | :(


Aidman » over and out
AnswerRe: Declaring Class function error? Pin
Anonymous14-Jun-03 13:57
Anonymous14-Jun-03 13:57 
GeneralRe: Declaring Class function error? Pin
Aidman14-Jun-03 14:54
Aidman14-Jun-03 14:54 
GeneralCComboBoxEx and some kind of draw Pin
Deian14-Jun-03 12:12
Deian14-Jun-03 12:12 
GeneralRe: CComboBoxEx and some kind of draw Pin
Michael Dunn14-Jun-03 14:03
sitebuilderMichael Dunn14-Jun-03 14:03 
Generalinvisible window Pin
Steve L.14-Jun-03 9:55
Steve L.14-Jun-03 9:55 
GeneralRe: invisible window Pin
Michael Dunn14-Jun-03 10:21
sitebuilderMichael Dunn14-Jun-03 10:21 
GeneralMRU problem Pin
mariuszpopiolek14-Jun-03 8:12
mariuszpopiolek14-Jun-03 8:12 
GeneralRe: MRU problem Pin
Ryan Binns15-Jun-03 3:23
Ryan Binns15-Jun-03 3:23 
GeneralControl creation issues. Pin
jales14-Jun-03 7:41
jales14-Jun-03 7:41 
GeneralRe: Control creation issues. Pin
Gary R. Wheeler15-Jun-03 3:23
Gary R. Wheeler15-Jun-03 3:23 
GeneralRe: Control creation issues. Pin
jales15-Jun-03 22:25
jales15-Jun-03 22:25 
GeneralRe: Control creation issues. Pin
Gary R. Wheeler16-Jun-03 11:50
Gary R. Wheeler16-Jun-03 11:50 
GeneralRe: Control creation issues. Pin
jales16-Jun-03 23:27
jales16-Jun-03 23:27 
QuestionAccessing Class Methods from other source files ? Pin
Anonymous14-Jun-03 7:35
Anonymous14-Jun-03 7:35 
AnswerRe: Accessing Class Methods from other source files ? Pin
Gary R. Wheeler15-Jun-03 3:27
Gary R. Wheeler15-Jun-03 3:27 
GeneralVS .Net '02 vs VS '03 - static lib compatibility Pin
Chris Losinger14-Jun-03 6:02
professionalChris Losinger14-Jun-03 6:02 
QuestionHow to generate a random number? Pin
FlyingDancer14-Jun-03 2:38
FlyingDancer14-Jun-03 2:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.