Exceptions
Team LiB
Previous Section Next Section

Exceptions

Sometimes classes must provide access to internal handles for compatibility reasons, such as interfacing with legacy code or other systems. For example, std::basic_string offers access to its internal handle via the data and the c_str member functions for compatibility with functions that expect C-style pointersbut that presumably do not store those pointers or try to write through them! Such backdoor access functions are a necessary evil that should be used rarely and cautiously, and the conditions under which the handle remains valid must be carefully documented.

    Team LiB
    Previous Section Next Section