delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/06/28/14:00:22

From: "Adrian Smith" <Adrian AT atpelectronics DOT connectfree DOT co DOT uk>
Newsgroups: comp.os.msdos.djgpp
References: <39535e20 AT news DOT telinco DOT net> <39587ba3$1 AT news DOT telinco DOT net> <39588b61 DOT 13985194 AT news DOT freeserve DOT net>
Subject: Re: Pointers and Arrays (Newbie)
Date: Wed, 28 Jun 2000 09:40:32 +0100
Lines: 58
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-1-54.cvx3.telinco.net
Message-ID: <3959ba51@news.telinco.net>
NNTP-Posting-Host: news2.cluster1.telinco.net
X-Trace: 28 Jun 2000 09:41:53 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

That seems to cure it ! Could somebody explain to me why and what the
'extern' statement is used for in this context.

                                                      Cheers.


Steamer <dontmailme AT iname DOT com> wrote in message
news:39588b61 DOT 13985194 AT news DOT freeserve DOT net...
> Adrian Smith wrote:
>
> > 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.
>
> Change test.h to:
>
>
> #ifndef TEST_H
> #define TEST_H
>
> void show(void);
> extern const char * message;
>
> #endif
>
>
> and test.cpp to:
>
>
> #include <iostream>
> #include "test.h"
>
> using namespace std;
>
> const char * message = "This is a message";
>
> int main(void)
> {
>    show();
>    cout << message << endl;
>    return 0;
> }
>
>
> And test2.cpp to:
>
>
> #include <iostream>
> #include "test.h"
>
> using namespace std;
>
> void show(void)
> {
>     cout << message << endl;
>
> }


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019