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;
void* operator new(size_t t)
{
cout << " allocated " << t << endl;
void* ptr = malloc(t);
return ptr;
}
void operator delete(void* ptr)
{
cout << " deallocated\n";
free(ptr);
}
class test1
{
public:
test1(const string& s = "Avoiding small string optimization") : m_s(s) {}
void display()
{
cout << m_s << endl;
}
const string m_s;
};
class test2
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run