Trying a little exercise on overloading the <<. MSVC++ 6.0 will not compile because it says the << operator is ambiguous. It's not ambiguous to me, I know exactly what it's doing. But my compiler doesn't like it. Can anyone help ??
Here is the prototype:
Code:friend ostream& operator<<(ostream&, const IntegerSet&);
Here is the function definition:
Code:ostream& operator<<(ostream& output, const IntegerSet& Set) { output << "\n{ "; for (int j = 0; j < Set.range; j++) //range is a public variable of class IntegerSet if (Set.array[j] == 1) output << j << '\t'; //array is a public variable of class Integerset output << "}" << endl; return output; }
Here is an example use of the overloaded operator:
Code:cout << "set A = " << setA << endl;



LinkBack URL
About LinkBacks


