Вопрос об Обзоре кода - я должен позволить эту передачу auto_ptr как параметр?

Рассмотрите следующий пример кода, который я недавно видел в нашей кодовой базе:

void ClassA::ExportAnimation(auto_ptr<CAnimation> animation)
{
... does something
}

// calling method:
void classB::someMethod()
{
  auto_ptr<CAnimation> animation (new CAnimation(1,2));
  ClassA classAInstance;
  classAInstance.ExportAnimation(animation)
  ... do some more stuff
}

Я не люблю это - и записал бы это так:

void ClassA::ExportAnimation(CAnimation* animation)
{
    ... does something
}

// calling method:
void classB::someMethod()
{
  auto_ptr<CAnimation> animation (new CAnimation(1,2));
  ClassA classAInstance;
  classAInstance.ExportAnimation(animation.get())
  ... do some more stuff
}

но это - действительно проблема?

5
задан GarethOwen 9 August 2010 в 12:28
поделиться