public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: gcc: C++ 2D array initialisation problem
       [not found] <3A6381A9.9040701@ctam.com.au>
@ 2001-01-15 14:27 ` Brendan J Simon
  0 siblings, 0 replies; only message in thread
From: Brendan J Simon @ 2001-01-15 14:27 UTC (permalink / raw)
  To: gcc-help

Brendan J Simon wrote:

> I have a problem initialising a 2D array of a class.
> The problem only seems to show up if it is a const declaration.
> The sample code below gives the following error with g++ (ver 2.95.2)
> 
> array.cpp: In function `void 
> __static_initialization_and_destruction_0(int, int)':
> array.cpp:28: conversion from `const FOO[3]' to non-scalar type `FOO' 
> requested
> array.cpp:28: conversion from `const FOO[3]' to non-scalar type `FOO' 
> requested
> array.cpp:28: conversion from `const FOO[3]' to non-scalar type `FOO' 
> requested
> 
> Is this a g++ error or an error in the code ???
> 
> Please reply to me (brendan.simon@bigpond.com) as well as the list.
> Thanks for any advice, tips or pointers.
> Brendan Simon.
> 
> ----------------------------------------------------------------------------- 
> 
> #include <iostream>
> 
> enum VALUE { min, med, max };
> 
> class FOO
> {
>     public:
>         FOO( VALUE value ) : _value(value) { }
>         char _value;
> };
> 
> FOO foo1[3] =     { min, med, max };
> 
> FOO foo2[3][3] =     {
>         { min, med, max },
>         { min, max, med },
>         { max, med, min }
>     };
> 
> const FOO foo3[3] =     { min, med, max };
> 
> const FOO foo4[3][3] =     {
>         { min, med, max },
>         { min, max, med },
>         { max, med, min }
>     };
> 
> int main()
> {
>     return 0;
> }
> 


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2001-01-15 14:27 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <3A6381A9.9040701@ctam.com.au>
2001-01-15 14:27 ` gcc: C++ 2D array initialisation problem Brendan J Simon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).