"Stephen J. Fromm" <stephen.fromm@ verizon.net> wrote...[color=blue]
> I take it I cannot form a container of an array type? For example,
> stack<string[3]> parentStack;[/color]
On 29 Jul 2003 10:18:57 -0700, stephen.fromm@v erizon.net (Stephen J.
Fromm) wrote:
[color=blue]
>I take it I cannot form a container of an array type? For example,
> stack<string[3]> parentStack;
>
>TIA,
>
>sjfromm[/color]
You can have containers of arrays, but the declaration youv'e posted
above is faulty. Youv'e declared a stack where each element is 3
strings. This is fine in principle, but probaly what you should do is
declare a struct that defines the stack elements, then declare the
stack as a stack of those things, like this:
John Dibling wrote:
[color=blue]
> On 29 Jul 2003 10:18:57 -0700, stephen.fromm@v erizon.net (Stephen J.
> Fromm) wrote:
>[color=green]
>>I take it I cannot form a container of an array type? For example,
>> stack<string[3]> parentStack;
>>
>>TIA,
>>
>>sjfromm[/color]
>
> You can have containers of arrays,[/color]
No, you can't.
[color=blue]
> but the declaration youv'e posted
> above is faulty. Youv'e declared a stack where each element is 3
> strings. This is fine in principle,[/color]
No, it's not. Arrays are not assignable and as such, they cannot be used
as elements of standard containers. The above code should not be
accepted by your C++ compiler.
[color=blue]
> but probaly what you should do is
> declare a struct that defines the stack elements, then declare the
> stack as a stack of those things, like this:
>
> struct STRINGS
> {
> string m_Strings[3];
> }; // STRINGS
>
> int main()
> {
> std::stack<STRI NGS> stk;
> return 0;
> }[/color]
"Victor Bazarov" <v.Abazarov@att Abi.com> wrote in message news:<vidcq25k0 vspdb@corp.supe rnews.com>...[color=blue]
> "Stephen J. Fromm" <stephen.fromm@ verizon.net> wrote...[color=green]
> > I take it I cannot form a container of an array type? For example,
> > stack<string[3]> parentStack;[/color]
>
> Yes.[/color]
John Dibling <dib@substitute _my_full_last_n ame_here.com> wrote in message news:<n3bdiv8fi 4d777210ten38kq bhmlu2sodf@4ax. com>...[color=blue]
> On 29 Jul 2003 10:18:57 -0700, stephen.fromm@v erizon.net (Stephen J.
> Fromm) wrote:[/color]
Thanks for your reply.
[color=blue][color=green]
> >I take it I cannot form a container of an array type? For example,
> > stack<string[3]> parentStack;
> >
> >TIA,
> >
> >sjfromm[/color]
>
> You can have containers of arrays, but the declaration youv'e posted
> above is faulty. Youv'e declared a stack where each element is 3
> strings. This is fine in principle, but probaly what you should do is
> declare a struct that defines the stack elements, then declare the
> stack as a stack of those things, like this:[/color]
Right, that's what I ended up doing.
What I'm curious about is whether I can *directly* define a stack<...>
of an array or not. My compiler decidedly didn't like it.
"Stephen J. Fromm" <stephen.fromm@ verizon.net> wrote...[color=blue]
> "Victor Bazarov" <v.Abazarov@att Abi.com> wrote in message[/color]
news:<vidcq25k0 vspdb@corp.supe rnews.com>...[color=blue][color=green]
> > "Stephen J. Fromm" <stephen.fromm@ verizon.net> wrote...[color=darkred]
> > > I take it I cannot form a container of an array type? For example,
> > > stack<string[3]> parentStack;[/color]
> >
> > Yes.[/color]
>
> Victor,
>
> Yes, I can form, or yes, I cannot form?[/color]
Cannot. Arrays do not satisfy the requirements for contained
items: CopyContstructi ble and Assignable.
Comment