Re: [Dev-C++] static vector initialization
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Per W. <pw...@ia...> - 2002-10-16 11:18:47
|
Depends on compiler version. If you need backwards compatibility, it
shouldn't be used.
/Per W
On Wed, 16 Oct 2002, Daniel Glenfield wrote:
> I am sure that the only way to initialise static members si with a static=
=20
> member function, but I don't know about vectors.
>=20
> Is static const int size =3D 10; actually allowed?
>=20
>=20
>=20
>=20
>=20
>=20
> >From: Anderson Ilha dos Santos <ai...@if...>
> >To: dev...@li...
> >Subject: [Dev-C++] static vector initialization
> >Date: Mon, 14 Oct 2002 18:10:36 -0200
> >
> >
> >Greetings,
> >
> >I have been working on a set of utility functions that I gruped together=
on=20
> >an
> >entirely static class. The
> >private part of this class has a (static) STL vector container whose=20
> >components
> >I have had trouble to
> >intialize. My class partial listing can be given as below,
> >
> >// file utility.hpp
> >class Utility
> >{
> > // public interface ...
> >
> > private:
> > static const int size =3D 10;
> > static vector<double> vec;
> >}
> >
> >// file utility.cpp
> >#include "Utility.hpp"
> >const int Utility::size;
> >vector<double> Utility::vec( size );
> >
> >the private member 'size' can be directly initialized in the class body=
=20
> >because
> >it is a static
> >integral value. However, I was unable to intialize the vec components=20
> >(vec[0],
> >vec[1], etc.) directly
> >below the vector<double> vec declaration in the utility.cpp file, just a=
s I
> >would have for the other
> >static private members of the class. The only way I have found to=20
> >initiliaze
> >the vec components was
> >to use a new function, say 'void init_vec()', and then initialize the
> >components inside this new function.
> >
> >I would like to know whether this is indeed the case or if I am missing
> >something. The init_vec()
> >approach seems to be something like a "makeshift" constructor, and I wou=
ld
> >prefer to be able to
> >initialize the container components just as I would have to a usual stat=
ic
> >member.
> >
> >I will appreciate any advice you guys can give me.
> >
> > Regards, Anderson.
> >
> >
> >
> >
> >-------------------------------------------------------
> >This sf.net email is sponsored by:ThinkGeek
> >Welcome to geek heaven.
> >http://thinkgeek.com/sf
> >_______________________________________________
> >Dev-cpp-users mailing list
> >Dev...@li...
> >TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm
> >https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>=20
>=20
> _________________________________________________________________
> Broadband?=A0Dial-up? Get reliable MSN Internet Access.=20
> http://resourcecenter.msn.com/access/plans/default.asp
>=20
>=20
>=20
> -------------------------------------------------------
> This sf.net email is sponsored by: viaVerio will pay you up to
> $1,000 for every account that you consolidate with us.
> http://ad.doubleclick.net/clk;4749864;7604308;v?
> http://www.viaverio.com/consolidator/osdn.cfm
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>=20
|