One more shot at this const thing.

Andrei Khropov andkhropov at nospam_mtu-net.ru
Thu Jul 27 17:36:05 PDT 2006


Reiner Pope wrote:

Should be:

----------------------------------------------------------
   const char[] c;
   char* ptr = c.ptr; // Compilation error: cannot cast away const
   *ptr = 5; 
----------------------------------------------------------
   const char[] c;
   const char* ptr = c.ptr; // ok: pointer to const char
   *ptr = 5; 			 // Compilation error: try to assign to a const value
----------------------------------------------------------

That's how it works in C++ (and it's correct).

The only way to break this system is to use explicit casts.


-- 
AKhropov



More information about the Digitalmars-d mailing list