Boost logo

Boost Users :

From: JOAQUIN LOPEZ MU?Z (joaquin_at_[hidden])
Date: 2007-08-05 04:30:57


----- Mensaje original -----
De: chun ping wang <cablepuff_at_[hidden]>
Fecha: Domingo, Agosto 5, 2007 7:09 am
Asunto: [Boost-users] boost array problems.
Para: boost-users_at_[hidden], solutions_at_[hidden]

> Hi I have a
>
> struct People
> {
> const char* fname_;
> const char* lname_;
> unsigned int id;
> }
>
> I want to create an array of 3 people.
>
> boost::array<People, 3> = {
> {"Chun", "Wang", 1441},
> {"Chia", "Wang", 1443},
> {"Ta", "Wang", 1445}
> };
>
> I get a compile time error too many initializer.

Use an added level of brace enclosing:

{{
{"Chun", "Wang", 1441},
{"Chia", "Wang", 1443},
{"Ta", "Wang", 1445}
}};

See http://boost.org/doc/html/array/rationale.html for
more details. HTH,

Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net