How new and delete operator works when create and delete object in C++

1 Answer

0 votes
#include <iostream>

using std::cout;
using std::endl;

class Test
{
public:
	Test()
	{
		cout << "Constructor" << endl;
	}
	~Test()
	{
		cout << "Destructor" << endl;
	}
};

int main()
{
	Test *p = new Test();

	delete p;

	return 0;
}


/*
run:

Constructor
Destructor

*/

 



answered Feb 17, 2018 by avibootz
...