c++小语句错在那里?
#include<iostream.h>
void main()
{
const int num =500; //有错误吗
int& ref=num;
cout << ref << endl;
ref=ref+100;
cout<<ref<<endl;
cout<<num<<endl;
}
提示:
--------------------Configuration: Cpp1 - Win32 Debug--------------------
Compiling...
Cpp1.cpp
C:\Documents and Settings\Administrator\Cpp1.cpp(5) : error C2440: 'initializing' : cannot convert from 'const int' to 'int &'
A reference that is not to 'const' cannot be bound to a non-lvalue
Error executing cl.exe.
Cpp1.obj - 1 error(s), 0 warning(s)
Thank you !