1.

What Is Transitive Const?

Answer»

Transitive CONST means that once const is applied to a TYPE, it applies RECURSIVELY to every sub-component of that type. HENCE:

const(INT*)** p;
p += 1; // ok, p is mutable
*p += 1; // ok, *p is mutable
**p += 1; // error, **p is const
***p += 1; // error, ***p is const

With transitivity, there is no way to have a const pointer to mutable int.

C++ const is not transitive.

Transitive const means that once const is applied to a type, it applies recursively to every sub-component of that type. Hence:

const(int*)** p;
p += 1; // ok, p is mutable
*p += 1; // ok, *p is mutable
**p += 1; // error, **p is const
***p += 1; // error, ***p is const

With transitivity, there is no way to have a const pointer to mutable int.

C++ const is not transitive.



Discussion

No Comment Found