[Live-devel] createNew explanations

Ross Finlayson finlayson at live555.com
Wed May 13 02:27:50 PDT 2015


> I'm currently using your library live555 and I'd like to know for which reason your prefer to use a static "createNew" function for each classes instead of constructors?
> It seems it has been done for a specific reason and I'm interested to know why :)

Yes, this was done to force developers to create these objects on the heap, rather than on the stack.

Creating these objects on the heap makes it easy for the class to be subclassed later, if you wish.  If the class is later subclassed, then you can create new objects of the subclass just by changing the implementation of the “createNew()” function - and the rest of the existing code will still work.  But if the objects were created on the stack, then it would not be possible for the class to be later subclassed.

Ross Finlayson
Live Networks, Inc.
http://www.live555.com/

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.live555.com/pipermail/live-devel/attachments/20150513/522f6ec8/attachment.html>


More information about the live-devel mailing list