Skip to main content
please don't use `code formatting` for emphasis: https://meta.stackexchange.com/q/135112/295232
Source Link
Glorfindel
  • 3.2k
  • 6
  • 28
  • 34

In The C++ Programming Language'The C++ Programming Language' the author Bjarne Stroustrup writes:

The protection of private data relies on restriction of the use of the class member names. It can therefore be circumvented by address manipulation and explicit type conversion. But this, of course, is cheating, C++ protects against accident rather than deliberate circumvention (fraud). Only hardware can offer perfect protection against malicious use of a general-purpose language, and even that is hard to do in realistic systems.

It can be said that manipulation is legal but it is a bad practice to preform such manipulations on private member variables.

In The C++ Programming Language the author Bjarne Stroustrup writes

The protection of private data relies on restriction of the use of the class member names. It can therefore be circumvented by address manipulation and explicit type conversion. But this, of course, is cheating, C++ protects against accident rather than deliberate circumvention (fraud). Only hardware can offer perfect protection against malicious use of a general-purpose language, and even that is hard to do in realistic systems.

It can be said that manipulation is legal but it is a bad practice to preform such manipulations on private member variables.

In 'The C++ Programming Language' the author Bjarne Stroustrup writes:

The protection of private data relies on restriction of the use of the class member names. It can therefore be circumvented by address manipulation and explicit type conversion. But this, of course, is cheating, C++ protects against accident rather than deliberate circumvention (fraud). Only hardware can offer perfect protection against malicious use of a general-purpose language, and even that is hard to do in realistic systems.

It can be said that manipulation is legal but it is a bad practice to preform such manipulations on private member variables.

Source Link

In The C++ Programming Language the author Bjarne Stroustrup writes

The protection of private data relies on restriction of the use of the class member names. It can therefore be circumvented by address manipulation and explicit type conversion. But this, of course, is cheating, C++ protects against accident rather than deliberate circumvention (fraud). Only hardware can offer perfect protection against malicious use of a general-purpose language, and even that is hard to do in realistic systems.

It can be said that manipulation is legal but it is a bad practice to preform such manipulations on private member variables.