www.digitalmars.com Home | Search | C & C++ | D | DMDScript | News Groups | index | prev | next
Archives

D Programming
D
D.gnu
digitalmars.D
digitalmars.D.bugs
digitalmars.D.dtl
digitalmars.D.dwt
digitalmars.D.announce
digitalmars.D.learn
digitalmars.D.debugger

C/C++ Programming
c++
c++.announce
c++.atl
c++.beta
c++.chat
c++.command-line
c++.dos
c++.dos.16-bits
c++.dos.32-bits
c++.idde
c++.mfc
c++.rtl
c++.stl
c++.stl.hp
c++.stl.port
c++.stl.sgi
c++.stlsoft
c++.windows
c++.windows.16-bits
c++.windows.32-bits
c++.wxwindows

digitalmars.empire
digitalmars.DMDScript

c++ - enum error?

↑ ↓ ← "CY" <lcy hkem.com> writes:
I have written a small piece of code as follows:

#include <iostream.h>
int main() {
 enum num {one=1,two,three,four,five};
 num x = three;
 cout << "x=" << x << endl;
 return 0;
}

But when I compile with DM compiler it gives this error:

C:\dm\bin>sc test.cpp
        cout << "x=" << x << endl;
                           ^
test.cpp(6) : Error: ambiguous reference to symbol
Had: ostream::operator <<(char )
and: ostream::operator <<(long double )
--- errorlevel 1

What does it mean and how can I solve this? There is no problem when I
compile it using VC++.

Thanks!
Aug 05 2002
↑ ↓ → Jan Knepper <jan smartsoft.cc> writes:
CY wrote:

 I have written a small piece of code as follows:

 #include <iostream.h>
 int main() {
  enum num {one=1,two,three,four,five};
  num x = three;
  cout << "x=" << x << endl;
  return 0;
 }

 But when I compile with DM compiler it gives this error:

 C:\dm\bin>sc test.cpp
         cout << "x=" << x << endl;

cout << "x=" << ( int ) x << endl;
 test.cpp(6) : Error: ambiguous reference to symbol
 Had: ostream::operator <<(char )
 and: ostream::operator <<(long double )
 --- errorlevel 1

 What does it mean and how can I solve this? There is no problem when I
 compile it using VC++.

Jan
Aug 05 2002