home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / gnu / g / help / 1185 < prev    next >
Encoding:
Text File  |  1992-09-03  |  1.7 KB  |  96 lines

  1. Path: sparky!uunet!munnari.oz.au!sol.deakin.OZ.AU!legolas!renagade
  2. From: renagade@legolas.deakin.oz.au (Mark Kuzmycz, SD 128, 2881)
  3. Newsgroups: gnu.g++.help
  4. Subject: type conversion required
  5. Date: 2 Sep 1992 07:14:32 GMT
  6. Organization: Sun Microsystems, Inc.
  7. Lines: 83
  8. Distribution: world
  9. Message-ID: <181pkoINNds4@sol.deakin.OZ.AU>
  10. Reply-To: renagade@legolas.deakin.oz.au
  11. NNTP-Posting-Host: legolas.cm.deakin.oz.au
  12.  
  13.  
  14. I have the following compiler message::
  15.  
  16. /usr/local/gnu/g++ -O -I ../Include/ -target sun4 -c test.C
  17. test.C: In function `int  main ()':
  18. test.C:68: type conversion required for type `List<Set>'
  19. *** Error code 1
  20.  
  21. Is this a compiler bug or am I doing something wrong?? The code is...
  22. include "list.h"
  23. #include "set.h"
  24. #include <iostream.h>
  25.  
  26. #include "../Utilities/list.C"
  27.  
  28. ostream& operator <<(ostream& os, List<Set>& list)
  29. {
  30.   for(int i=0; i < list.size(); i++)
  31.   {
  32.     os << "< ";
  33.     for(int j = 0; j < list[i].maxSize(); j++)
  34.     {
  35.       if(list[i] == j)
  36.       {
  37.         os << " " << (char)('A'+j) << " ";
  38.       }
  39.       else
  40.       {
  41.         os << "~" << (char)('A'+j) << " ";
  42.       }
  43.     }
  44.     os << ">";
  45.  
  46.     os <<"\n";
  47.   }
  48.   return(os);
  49. }
  50.  
  51. int power(int number)
  52. {
  53.   int value = 1;
  54.  
  55.   for(int i =0; i < number; i++)
  56.   {
  57.     value *= 2;
  58.   }
  59.   return(value);
  60. }
  61.  
  62. main()
  63. {
  64.   int size;
  65.  
  66.   cout << "Enter size:" << flush;
  67.   cin >> size;
  68.  
  69.   int number = power(size);
  70.   Set base(size);
  71.  
  72.   int index = 0;
  73.   List<Set> list;
  74.  
  75.   list.add(base);
  76.  
  77.   for(int i=1; i < number; i++)
  78.   {
  79.     while(base == index)
  80.     {
  81.       base -= index;
  82.       index++;
  83.     }
  84.     base += index;
  85.     cout << base;
  86.     index = 0;
  87.     list.add(base);
  88.   }
  89.   cout << list;   // line # 68....
  90. }
  91.  
  92. As you can see I have a List<Set> output operator so why does it want to cast?
  93.  
  94.  
  95. Mark.
  96.