<<< | Index | >>> |
|
// String.h class String { public: void reserve( int size ) const; private: mutable int m_buffer_size; mutable char* m_ptr_buffer; }; // String.cpp void String::reserve( int size ) const { if( m_buffer_size < size ) { // reallocate buffer memory, then copy // current string there, then... m_buffer_size = size; // OK, because // m_buffer_size declared mutable } } void myfunc( String const& str ) { str.reserve( 1024 ); // Ok } |
<<< | Index | >>> |