- in most cases, do not throw in the destructor. let the destroctor finishes its job.
- have a nice default constructor; if something is wrong, the object is not even constructed. you don't have to worry about the object state. it's not even exists yet, and all internal stuff are clean out by destructor(s).
template
Stack::Stack()
: v_(new T[10]), // default allocation
vsize_(10),
vused_(0) // nothing used yet
{
}
No comments:
Post a Comment