Previous |Next |

 

2.1    Storage Management

C++ defines two functions for storage management,
         new (for storage allocation)
         delete(for de-allocation).

The syntax for new is
              pointer = new <type> or
              pointer = new <type> [<size>]

QUESTION:
            What advantage(s) does new have over malloc or calloc?
 ANSWER:





The syntax for delete is delete <object> or delete [] <object>
The private getBuffer function called by the constructors inline void String::getBuffer(const unsigned int Max_Length) { Buffer_Len = Max_Length + 1; Buffer = new char [ Buffer_Len ]; if( !Buffer ) Error( "Out of space" ); }
Previous |Next |