From: "Adrian Smith" Newsgroups: comp.os.msdos.djgpp References: <39535e20 AT news DOT telinco DOT net> Subject: Re: Pointers and Arrays (Newbie) Date: Tue, 27 Jun 2000 10:56:30 +0100 Lines: 84 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.00.2014.211 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2014.211 X-Original-NNTP-Posting-Host: ppp-2-76.cvx3.telinco.net Message-ID: <39587ba3$1@news.telinco.net> NNTP-Posting-Host: news2.cluster1.telinco.net X-Trace: 27 Jun 2000 10:57:58 GMT, news2.cluster1.telinco.net To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Sorry to be a pain, but I thought I'd solved the problem when I hadn't. I've realised where the problem lies but I can't work out why. The problem is, I've got two <.cpp> files which both use the same <.h> header file. The header file contains :- (filename - test.h) #ifndef TEST_H #define TEST_H void show(void); const char * message = "This is a message"; #endif The two .cpp files are as follows :- (filename test.cpp) #include #include #include "test.h" int main(void) { show(); cout << message << endl; } (filename test2.cpp) #include "test.h" #include void show(void) { cout << message << endl; } Using Rhide these two .cpp files will compile perfectly o.k. but when you try to link them into test.exe they complain of this multiple defenition error as mentioned in the previous post. Using an array of chars ie. const char message[30] = "This is a message". in the header file seems to work fine ?? The solution is probably obvious - if so could somebody tell me what's up . Thanks. Adrian Smith wrote in message news:39535e20 AT news DOT telinco DOT net... > Can anybody help me ? > > My program has a header file in which I've got :- > > const char * message = "This is an error message \n" > > In the main .cpp file I've got :- > > cout << message << endl; > > When i try to compile, it comes up with:- > > error : : multiple defenition of 'message' > > If i use an array - ie, const char message[30] = "This is an error message > \n" > this works perfectly. Could somebody please tell me where Iam going wrong > with the pointer method. > > Many thanks. > > >