Talk:C++ string handling
Appearance
![]() | C/C++ Unassessed | |||||||||
|
mem usage?
I just had a young programmer tell me that an uninitialized std::string uses less memory than an initialized one. Is that true? (I guess that would depend on the implementation; but consider, for example gcc) The code I found suspect was:
class blah { private: std:string name; public: blah (std:string in) { if (!in.empty()) name = in; // claimed savings of memory } };
linas (talk) 03:31, 27 January 2008 (UTC)
- That sounds bogus to me. Even if you don't touch
name
, it gets initialized at the beginning of the constructor. —Ben FrantzDale (talk) 06:10, 27 January 2008 (UTC)