K
kk
I am trying to compile a list of items in the C++ language where it
offers some protections from the compiler that prevent the user from
making mistakes and in other areas total freedom to do what you want at
your own risk. For example, I would say the const keyword is an
overloaded keyword that offers protection on various fronts like const
variables(compiler prevents you from accidentally modifying these
variables), const member functions( compiler prevents you from
accidentally modifying the object on which the method is invoked), the
dynamic_cast ( a mechanism through which you can check the safety of
you casting operation), encapsulation through use of scope modifiers to
prevent users from accidentally modifying private data, etc.
On the other hand, the freedom to do anything at your own risk is
provided by way of the ability to directly access raw memory through
pointers, usage of reinterpret_cast to cast one type to a different
type, placement new and delete to specifically play around with
memory, etc.
Need help to compile more of these.
thanks
offers some protections from the compiler that prevent the user from
making mistakes and in other areas total freedom to do what you want at
your own risk. For example, I would say the const keyword is an
overloaded keyword that offers protection on various fronts like const
variables(compiler prevents you from accidentally modifying these
variables), const member functions( compiler prevents you from
accidentally modifying the object on which the method is invoked), the
dynamic_cast ( a mechanism through which you can check the safety of
you casting operation), encapsulation through use of scope modifiers to
prevent users from accidentally modifying private data, etc.
On the other hand, the freedom to do anything at your own risk is
provided by way of the ability to directly access raw memory through
pointers, usage of reinterpret_cast to cast one type to a different
type, placement new and delete to specifically play around with
memory, etc.
Need help to compile more of these.
thanks