What is the difference between new
/delete
and malloc
/free
?
Related (duplicate?): In what cases do I use malloc vs
This code for use of delete keyword or free function. But when create a pointer object using 'malloc' or 'new' and deallocate object memory using delete even that object pointer can be call function in the class. After that use free instead of delete then also it works after free statement , but when use both then only pointer object can't call to function in class.. the code is as follows :
#include
using namespace std;
class ABC{
public: ABC(){
cout<<"Hello"<disp();
cout<disp();
ABC();
cout<
output :
Hello Hi 0x2abfef37cc20