It is possible that exceptions might raise in a constructor or destructor. If an exception is raised in a constructor, memory might be allocated to some data member and might not be allocated for others. This might lead to memory leakage problem as the program stop and the memory for data members stays alive in the RAM. Similarly, when an exception is raised in a destructor, memory might not be deallocated which may again lead to memory leakage problems. So, it is better to provide exception handling within the constructor and destructor to avoid such problems. Following program demonstrates
The post How to perform exception handling when working with constructors and destructors appeared first on Coding Security.
How to perform exception handling when working with constructors and destructors
read more
Tidak ada komentar:
Posting Komentar