示例#1
0
// The square root function for numbers
CNumber &Sqrt(CNumber &num) {
  CNumber *pnumSqrt;
  if(! num.Defined()) {throw ELENotDefined; }
  
  pnumSqrt = new CNumber(sqrt(double(num)));	// Make a deep copy of the original
  pnumSqrt->SetAllocated(true);		// We allocated the memory space

  if(num.Allocated()) {delete # } // This should call for the destructor
  return *pnumSqrt;
} // Sqrt