1 Answers
Code:
#include <iostream>
using namespace std;
class test
{
int *a;
public:
test(int size)
{
a = new int[size];
cout<<“Constructor msg: Integer array of size : “<<size;
}
~test()
{
delete a;
cout<<“Deconstructor : deleted memory”;
}
};
int main()
{
int s;
cout<<“Enter size:”;
cin>>s;
test T(s);
cout<<endl;
return 0;
}
Output:
Enter size:4
Constructor msg: Integer array of size : 4
Deconstructor : deleted memory