Your code is valid (if the functionCall () function actually guarantees that the pointer will be deleted), but it is fragile and will cause the audio signals to go blank in the heads of most C ++ programmers.
There are several problems in the code:
- , ? ? , . , , -, . , , , , , delete , !
- , , . , :
functionCall(new className(initializers), new className(initializers)); , , (, , , , ). functionCall .
( ) , , , ( ):
className* p = new className(initializers);
functionCall(p);
delete p;
. , functionCall ? p . / , , .
, FunctionCall, ? , . . .
, :
boost::shared_ptr<className> p = boost::shared_ptr<className>(new className(initializers));
functionCall(p);
. shared_ptr , . , std::auto_ptr, shared_ptr , .
, , , , - . , .
, , , .
RAII.
className , , new . . , , , , :
functionCall(className(initializers));
++ . std::vector - . new. .