On Sun, 04 Jul 2004 08:42:06 GMT, crichmon <> wrote:
> Is there away to initialize an array's size through constructor
> initialization?
>
> Right now I have
>
> ///////////////
> class foo
> {
> string bar[20];
> public:
> foo();
> }
>
> ////
> foo::foo()
> {
> };
>
>
> ////////////////
>
> could something be done like
>
> ///////////////
> class foo
> {
> string bar[];
> public:
> foo();
> }
>
> ////
> foo::foo(): bar[20]
> {
> };
>
>
> ////////////////
>
> Any help?
>
> thanks,
> crichmon
>
>
Use a vector
class foo
{
vector<string> bar;
public:
foo();
}
////
foo::foo(): bar(20)
{
};
It's what vectors are for.
john
|