home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!munnari.oz.au!sol.deakin.OZ.AU!legolas!renagade
- From: renagade@legolas.deakin.oz.au (Mark Kuzmycz, SD 128, 2881)
- Newsgroups: gnu.g++.help
- Subject: type conversion required
- Date: 2 Sep 1992 07:14:32 GMT
- Organization: Sun Microsystems, Inc.
- Lines: 83
- Distribution: world
- Message-ID: <181pkoINNds4@sol.deakin.OZ.AU>
- Reply-To: renagade@legolas.deakin.oz.au
- NNTP-Posting-Host: legolas.cm.deakin.oz.au
-
-
- I have the following compiler message::
-
- /usr/local/gnu/g++ -O -I ../Include/ -target sun4 -c test.C
- test.C: In function `int main ()':
- test.C:68: type conversion required for type `List<Set>'
- *** Error code 1
-
- Is this a compiler bug or am I doing something wrong?? The code is...
- include "list.h"
- #include "set.h"
- #include <iostream.h>
-
- #include "../Utilities/list.C"
-
- ostream& operator <<(ostream& os, List<Set>& list)
- {
- for(int i=0; i < list.size(); i++)
- {
- os << "< ";
- for(int j = 0; j < list[i].maxSize(); j++)
- {
- if(list[i] == j)
- {
- os << " " << (char)('A'+j) << " ";
- }
- else
- {
- os << "~" << (char)('A'+j) << " ";
- }
- }
- os << ">";
-
- os <<"\n";
- }
- return(os);
- }
-
- int power(int number)
- {
- int value = 1;
-
- for(int i =0; i < number; i++)
- {
- value *= 2;
- }
- return(value);
- }
-
- main()
- {
- int size;
-
- cout << "Enter size:" << flush;
- cin >> size;
-
- int number = power(size);
- Set base(size);
-
- int index = 0;
- List<Set> list;
-
- list.add(base);
-
- for(int i=1; i < number; i++)
- {
- while(base == index)
- {
- base -= index;
- index++;
- }
- base += index;
- cout << base;
- index = 0;
- list.add(base);
- }
- cout << list; // line # 68....
- }
-
- As you can see I have a List<Set> output operator so why does it want to cast?
-
-
- Mark.
-