Re: [Dev-C++] static vector initialization
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Daniel G. <sp...@ho...> - 2002-10-16 11:06:28
|
I am sure that the only way to initialise static members si with a static
member function, but I don't know about vectors.
Is static const int size = 10; actually allowed?
>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
>an
>entirely static class. The
>private part of this class has a (static) STL vector container whose
>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 = 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
>because
>it is a static
>integral value. However, I was unable to intialize the vec components
>(vec[0],
>vec[1], etc.) directly
>below the vector<double> vec declaration in the utility.cpp file, just as I
>would have for the other
>static private members of the class. The only way I have found to
>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 would
>prefer to be able to
>initialize the container components just as I would have to a usual static
>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
_________________________________________________________________
Broadband? Dial-up? Get reliable MSN Internet Access.
http://resourcecenter.msn.com/access/plans/default.asp
|