[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++ STL helvede



> From sslug@sslug  Wed May 22 14:06:16 2002
> Subject: [CPROG] C++ STL helvede
>
> Hejsa
>
> Jeg har et program der barfer med:
>
> source='frame_generator.cpp' object='frame_generator.o' libtool=no \
> depfile='.deps/frame_generator.Po' tmpdepfile='.deps/frame_generator.TPo' 
> \
> depmode=gcc3 /bin/sh ../depcomp \
> g++-3.0.4 -DPACKAGE=\"dv_script_renderer\" -DVERSION=\"0.0.3\" -Dconst=  
> -I. -I.
>  -I/usr/include/glib-1.2 -I/usr/lib/glib/include  -I/scratch/Cvs/libdv/  
> -g -O2
> -c -o frame_generator.o `test -f frame_generator.cpp || echo 
> './'`frame_generato
> r.cpp
> In file included from /usr/include/g++-v3/bits/fpos.h:39,
>                  from /usr/include/g++-v3/bits/std_iosfwd.h:41,
>                  from /usr/include/g++-v3/bits/std_ios.h:39,
>                  from /usr/include/g++-v3/bits/std_istream.h:39,
>                  from /usr/include/g++-v3/bits/std_fstream.h:39,
>                  from /usr/include/g++-v3/fstream:31,
>                  from frame_generator.cpp:27:
> /usr/include/g++-v3/i586-mandrake-linux-gnu/bits/c++io.h:60: ISO C++ 
> forbids
>    in-class initialization of non-const static member `_S_boolalpha'
> /usr/include/g++-v3/i586-mandrake-linux-gnu/bits/c++io.h:61: ISO C++ 
> forbids
>    in-class initialization of non-const static member `_S_dec'
>
> osv... .
>
> Nogen der er stærke nok i c++ til at se om det er noget jeg kan gøre noget 
> ved? (gcc 3.0.4 Mandrake 8.2. gcc 2.96 har tilsvarende problemer).
>
> Mads
>

Du har sikkert en

class Narko {
	static int gnidder = 5;

	Narko() {
		// blidder
	}
};

(eller noget i samme stil). Fjern = 5, ideen er at lave noget i stil
med

class Narko {
	static int gnidder;

	Narko(): gnidder(5) {
		// blidder
	}
};

Det er ikke sikkert det vil virker bagefter, det afhaenger af hvordan
gnidder skal bruges.

Problemet er at gnidder er static (dvs. delt mellem alle objekter af
en given klasse) men ikke const (dvs. den kan aendres i et objekt, og
aendres i alle objekter). Det kan fx bruges til globale counters.

Det er dog meget muligt at det slet ikke er i std-biblioteket problemet
er. Ofte knaekker man halsen paa at have lavet noget const eller ikke
const.

Inkluderer du måske noget før fstream, som indeholder en klassedefinition,
som ikke slutter med ;?

Et standard trick ved C++ fejl er at se paa de foerste par linjer (in-class
blahblah) og de sidste par linjer, som fortaeller hvad der gaar galt.

(Det kan med andre ord vaere mange ting)

-- 
   _______
  /       \    Michael Westergaard <sslug@sslug>
 / /|/|  \ \   http://klafbang.dk/
( ( ` |   ) )
 \ \  |/\/ /   Mit ur går stadig efter vintertid. Det giver en
  \_______/    dejlig, men falsk, følelse af at have god tid.


 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-08-10, 20:09 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] *