[Cg1] Re: No deconstructor for renderer?

Pascal Grittmann s9pagrit at stud.uni-saarland.de
Sun Oct 30 12:31:38 CET 2016


The camera object that is passed to the renderer as a pointer is  
created in the a_cameras() function. There are two reasons why you  
should under no circumstances delete this camera object in the d'tor  
of the renderer class:

1. The renderer class is not the (only) owner of the resource, the  
camera might be used after the renderer is destroyed!
2. The camera object was created on the stack, trying to use delete on  
a stack pointer will break your program.

Best,
Pascal


Zitat von Noshaba Cheema <s8nochee at stud.uni-saarland.de>:

> Hello,
>
> why is there no declaration for a custom deconstructor in the  
> renderer class? As it has pointers as members, which should be  
> deleted when renderer is deleted or not?
>
> Best,
> Noshaba
>
> _______________________________________________
> Cg1 mailing list
> Cg1 at cg.uni-saarland.de
> http://mail.cg.uni-saarland.de/mailman/listinfo/cg1





More information about the Cg1 mailing list