[comp.lang.c++] Bug with const declarations.

mlijews@NSWC-WO.ARPA (06/14/88)

     The following program is adapted from Stoustrup's book.  Shouldn't the
const int vec[] yield a warning during compilation like const int one and
shouldn't it not be posible to change vec[1] to 2?

PROGRAM:

#include <stream.h>

main()
{
	const int one = 1;
	one = 2;	// error

	const int vec[] = {1,2};
	vec[1] = 2;	// should be error

	cout << "one = " << one << "\nvec[1] = " << vec[1] << "\n";
}

COMPILATION and OUTPUT:

In function int main ():
test9.cc:6: warning: assignment of read-only variable `one'

one = 1
vec[1] = 2