想学C++,找了点代码看并编译,发现VC6下会报错,不知道为什么?谢谢帮忙!
并请告知如何解决?
#include <iostream.h>
// #include <iostream>
/**
**
the while loop has executed 1 times
the while loop has executed 2 times
the while loop has executed 3 times
the while loop has executed 4 times
the while loop has executed 5 times
**
**/
int main()
{
int iterations = 0;
bool continue_loop = true;
while ( continue_loop != false )
{
iterations++;
cout << "the while loop has executed "
<< iterations << " times\n";
if ( iterations == 5 )
continue_loop = false;
}
return 0;
}
--------------------Configuration: alg0 - Win32 Debug--------------------
Compiling...
alg0.c
E:\Chg\mine\CC++\Code\alg0.c(16) : error C2065:
'bool' : undeclared identifier
E:\Chg\mine\CC++\Code\alg0.c(16) : error C2146: syntax error : missing ';' before identifier 'continue_loop'
E:\Chg\mine\CC++\Code\alg0.c(16) : error C2065: 'continue_loop' : undeclared identifier
E:\Chg\mine\CC++\Code\alg0.c(16) : error C2065: 'true' : undeclared identifier
E:\Chg\mine\CC++\Code\alg0.c(18) : error C2065: 'false' : undeclared identifier
E:\Chg\mine\CC++\Code\alg0.c(22) : error C2065: 'cout' : undeclared identifier
E:\Chg\mine\CC++\Code\alg0.c(23) : error C2297: '<<' : illegal, right operand has type 'char [29]'
Error executing cl.exe.
alg0.exe - 7 error(s), 0 warning(s)