3 ms·
C++ doesn’t really have an ownership system. You can use certain language features to implement certain kinds of ownership discipline, but the language itself d
by foldr 9mo ago
C++ doesn’t really have an ownership system. You can use certain language features to implement certain kinds of ownership discipline, but the language itself doesn’t really have an opinion on who should own what. For example, the article talks about cases where a returned value “must” be deallocated by the calling code, but there is no “must” about it as far as the language is concerned. You’re perfectly at liberty to allocate something without ever freeing it (and this isn’t even a memory leak if the value is needed throughout the lifetime of the program).