www.digitalmars.com         C & C++   DMDScript  

c++.stl - problem with cin >> bool

reply "Winfried Mevenkamp" <gemi_gmbh t-online.de> writes:
Hi

This simple program compiled with DMC 8.34

#include <iostream.h>
using namespace std;

int main() {
   bool b;
   short n;

   cin  >> n >> b;
   cout << n << b;

   return 0;
}

gives me the following error message

dmc main.cpp -A -c -s -mld -v1 -o -3
   cin  >> n >> b;
                        ^
main.cpp(9) : Error: reference must refer to same type or be const
Had: bool
and: int &
main.cpp(14) : Error: need at least one external def
--- errorlevel 1

any ideas ?

Winfried
Aug 13 2003
parent "Walter" <walter digitalmars.com> writes:
Try using the more modern iostream, which is <iostream>. Be sure to set the
include path to include \dm\stlport\stlport.

"Winfried Mevenkamp" <gemi_gmbh t-online.de> wrote in message
news:bhd6gu$7f6$1 digitaldaemon.com...
 Hi

 This simple program compiled with DMC 8.34

 #include <iostream.h>
 using namespace std;

 int main() {
    bool b;
    short n;

    cin  >> n >> b;
    cout << n << b;

    return 0;
 }

 gives me the following error message

 dmc main.cpp -A -c -s -mld -v1 -o -3
    cin  >> n >> b;
                         ^
 main.cpp(9) : Error: reference must refer to same type or be const
 Had: bool
 and: int &
 main.cpp(14) : Error: need at least one external def
 --- errorlevel 1

 any ideas ?

 Winfried

Aug 13 2003