home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / lang / cplus / 13359 < prev    next >
Encoding:
Text File  |  1992-09-08  |  2.5 KB  |  96 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!psgrain!hippo!cshl2.ru.ac.za!g89s9112
  3. From: g89s9112@giraffe.ru.ac.za (MR D STURZEBECHER)
  4. Subject: initialization HELP structure of classes
  5. Message-ID: <g89s9112.2.715860452@giraffe.ru.ac.za>
  6. Lines: 84
  7. Sender: news@hippo.ru.ac.za
  8. Organization: Rhodes University, Grahamstown, South Africa
  9. Distribution: global
  10. Date: Mon, 7 Sep 1992 10:07:32 GMT
  11.  
  12. Hi,
  13. I got a problem I do not understand. I am new to C++, but have programmed
  14. C for quite a while.
  15.  
  16. The problem is the following. I did declare two classes
  17.  
  18. class digital ...
  19. class analog ...
  20.  
  21. both which work fine. Now I needed arrays of those, so I declared
  22.  
  23. digital dout[nr_dig];
  24. digital din [nr_dig];
  25. analog  aout[nr_ana];
  26. analog  ain;
  27.  
  28. which worked fine. Now I did want to group them, so that I got only one
  29. object to drag around so I declared
  30.  
  31. typedef struct A_DATA
  32.       {
  33.         char    header[maxx];    // header  string
  34.         digital dout[nr_dig];    // digital outputs (class digital)
  35.         digital din [nr_dig];    // digital inputs  (class digital)
  36.         analog  aout[nr_ana];    // analog  outputs (class digital)
  37.         analog  ain;        // analog  input   (class digital)
  38.       }DATA;
  39.  
  40. still everything going well. Now in main I tried to initalize the thing
  41.  
  42. void main(void)
  43. {
  44.   // declare/initialize the data
  45.   DATA data = {
  46.         "PPORT DEMO",
  47.         {
  48.           digital('1',"digital out 1 ","ON","OFF",0),
  49.           digital('2',"digital out 2 ","ON","OFF",0),
  50.           digital('3',"digital out 3 ","ON","OFF",0),
  51.           digital('4',"digital out 4 ","ON","OFF",0),
  52.           digital('5',"digital out 5 ","ON","OFF",0),
  53.           digital('6',"digital out 6 ","ON","OFF",0),
  54.           digital('7',"digital out 7 ","ON","OFF",0),
  55.           digital('8',"digital out 8 ","ON","OFF",0)
  56.         },
  57.         {
  58.           digital('a',"digital in  1 ","ON","OFF",0),
  59.           digital('b',"digital in  2 ","ON","OFF",0),
  60.           digital('c',"digital in  3 ","ON","OFF",0),
  61.           digital('d',"digital in  4 ","ON","OFF",0),
  62.           digital('e',"digital in  5 ","ON","OFF",0),
  63.           digital('f',"digital in  6 ","ON","OFF",0),
  64.           digital('g',"digital in  7 ","ON","OFF",0),
  65.           digital('h',"digital in  8 ","ON","OFF",0)
  66.         },
  67.         {
  68.           analog('n',"analog  out 1"),
  69.           analog('m',"analog  out 2")
  70.         },
  71.         analog ain('i',"analog  in  1")
  72.           };
  73.  
  74. .....
  75. }
  76.  
  77. PROBLEM !!
  78.  
  79. the compiler gives the following error message
  80.  
  81. ERROR : Objects of type 'A_DATA' cannot be initialized with {  }
  82.  
  83. WHY ??
  84.  
  85. what else can I try ??
  86.  
  87. Anybody ?
  88.  
  89. Cheers, Dirk
  90.  
  91.  
  92.  
  93. ----------------------------------------------------------------------------
  94. Dirk Sturzebecher
  95. g89s9112@beta.ru.ac.za
  96.