Re: why can't this be a feature in C++?
From: Janusz Szpilewski (janusz.szpilewski_at_symbian.com)
Date: 09/02/04
- Next message: Kleenex: "STL documentation / reference ???"
- Previous message: Richard Herring: "Re: Cpp Considered Harmful"
- In reply to: Paul: "why can't this be a feature in C++?"
- Next in thread: Alf P. Steinbach: "Re: why can't this be a feature in C++?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 02 Sep 2004 10:31:57 +0100
Paul wrote:
>
> int main()
> {
> A *p1 = new A[3](5); //all objects have same value
> A *p2 = new A[3]((5),(5,10),(20)); //objects have different values
> return 0;
> }
>
> Is there any reason for not having some thing like this, or just
> because of its complex to implement???
>
Array with elements initialised with a non-default constructor was
considered and probably still is implemented by the gcc compiler but
finally the idea was given up to the concept of fill constructor in the
sequence types in the STL library. Check any STL documentation for
further details.
It is used like:
std::vector<int> v(5,3); // vector of 5 ints filled with the 3 value.
or
std::vector<int>* vp = new std::vector<int> (5,3);
Regards,
Janusz
- Next message: Kleenex: "STL documentation / reference ???"
- Previous message: Richard Herring: "Re: Cpp Considered Harmful"
- In reply to: Paul: "why can't this be a feature in C++?"
- Next in thread: Alf P. Steinbach: "Re: why can't this be a feature in C++?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|