CPP
cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <iostream>
using namespace std;
class test
{
public:
test()
{cout << "ctor\n";a=22;}
~test()
{cout << "dtor\n";}
void display()
{cout << a << endl;}
private:
int a = -8;
};
int main()
{
auto a = (test*)calloc(2,sizeof(test));
auto b = (test*)malloc(1*sizeof(test));
a->display();
b->display();
free(a);
free(b);
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run