home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!psgrain!hippo!cshl2.ru.ac.za!g89s9112
- From: g89s9112@giraffe.ru.ac.za (MR D STURZEBECHER)
- Subject: initialization HELP structure of classes
- Message-ID: <g89s9112.2.715860452@giraffe.ru.ac.za>
- Lines: 84
- Sender: news@hippo.ru.ac.za
- Organization: Rhodes University, Grahamstown, South Africa
- Distribution: global
- Date: Mon, 7 Sep 1992 10:07:32 GMT
-
- Hi,
- I got a problem I do not understand. I am new to C++, but have programmed
- C for quite a while.
-
- The problem is the following. I did declare two classes
-
- class digital ...
- class analog ...
-
- both which work fine. Now I needed arrays of those, so I declared
-
- digital dout[nr_dig];
- digital din [nr_dig];
- analog aout[nr_ana];
- analog ain;
-
- which worked fine. Now I did want to group them, so that I got only one
- object to drag around so I declared
-
- typedef struct A_DATA
- {
- char header[maxx]; // header string
- digital dout[nr_dig]; // digital outputs (class digital)
- digital din [nr_dig]; // digital inputs (class digital)
- analog aout[nr_ana]; // analog outputs (class digital)
- analog ain; // analog input (class digital)
- }DATA;
-
- still everything going well. Now in main I tried to initalize the thing
-
- void main(void)
- {
- // declare/initialize the data
- DATA data = {
- "PPORT DEMO",
- {
- digital('1',"digital out 1 ","ON","OFF",0),
- digital('2',"digital out 2 ","ON","OFF",0),
- digital('3',"digital out 3 ","ON","OFF",0),
- digital('4',"digital out 4 ","ON","OFF",0),
- digital('5',"digital out 5 ","ON","OFF",0),
- digital('6',"digital out 6 ","ON","OFF",0),
- digital('7',"digital out 7 ","ON","OFF",0),
- digital('8',"digital out 8 ","ON","OFF",0)
- },
- {
- digital('a',"digital in 1 ","ON","OFF",0),
- digital('b',"digital in 2 ","ON","OFF",0),
- digital('c',"digital in 3 ","ON","OFF",0),
- digital('d',"digital in 4 ","ON","OFF",0),
- digital('e',"digital in 5 ","ON","OFF",0),
- digital('f',"digital in 6 ","ON","OFF",0),
- digital('g',"digital in 7 ","ON","OFF",0),
- digital('h',"digital in 8 ","ON","OFF",0)
- },
- {
- analog('n',"analog out 1"),
- analog('m',"analog out 2")
- },
- analog ain('i',"analog in 1")
- };
-
- .....
- }
-
- PROBLEM !!
-
- the compiler gives the following error message
-
- ERROR : Objects of type 'A_DATA' cannot be initialized with { }
-
- WHY ??
-
- what else can I try ??
-
- Anybody ?
-
- Cheers, Dirk
-
-
-
- ----------------------------------------------------------------------------
- Dirk Sturzebecher
- g89s9112@beta.ru.ac.za
-