[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [CPROG] C vs. C++ problem



On Wed, 14 Jul 1999, Sune Fischer wrote:

> jeg har prøvet at konvertere nogle programmer fra C til C++, men
> enkelte ting giver mig grå hår (og jeg er kun 23). Problemet kan skæres
> ned til følgende:
> Jeg har en del variable jeg ikke gider kaste rundt imellem
> funktionerne, og derfor vil jeg have dem globale. Desuden vil jeg have
> delt funktionerne ud på flere filer, og så er det problemerne opstår.
> Linkeren kommer med beskeder om at de variable allerede er defineret,
> her er et eksempel og det virker fint i C, men ikke i C++? 

> void Testfunk();
> int a, b, c[100];

Dette er en variabel *definition*. Den maa kun forekomme eet sted i
programmet. Naar du har en header fil, saa forekommer den ligesaa mange
gange som du inkluderer headerfilen.

Lav dem om til:

extern int a, b.... // deklaration -- den er definiteret andet steds!

og i *een* C-fil skriv:

int a,b, ...; // definition -- her er variablerne.

	
Det boer egentlig heler virke i C.


-- 
==============================================================================
Erwin Andreasen   Herlev, Denmark <sslug@sslug>           Lokale:  22, D3 (123)
<URL:http://www.andreasen.org/>        <*>      BQA/UNIX         Telefon: 2491
==============================================================================







 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-08-10, 20:07 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *