-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPoint.h
52 lines (42 loc) · 1.21 KB
/
Point.h
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
//
// Created by mark on 1/23/20.
//
#include <cstddef>
#include <iostream>
#include "algoNew.h"
using std::cout;
using std::endl;
using std::cin;
#ifndef MEMORYMANAGER_POINT_H
#define MEMORYMANAGER_POINT_H
class Point {
protected:
unsigned int x, y, z;
public:
Point (unsigned int xval = 0, unsigned int yval = 0, unsigned int zval = 0):
x(xval), y(yval), z(zval) {
cout << "Initializing Point Object with [" << x << ", "
<< y << ", " << z << "]." << endl;
}
~Point () {
cout << "Executing Point destructor" << endl;
}
void* operator new(size_t numBytes) {
cout << "Allocating Point with new: " << numBytes << " bytes." << endl;
return malloc(numBytes);
//return ::new Point;
}
void operator delete(void* ptr) {
cout << "De-allocating Point with delete." << endl;
free(ptr);
}
void* operator new[](size_t numBytes) {
cout << "Allocating Point Array with new[]: " << numBytes << " bytes." << endl;
return malloc(numBytes);
}
void operator delete[] (void* ptr) {
cout << "De-allocating Point array with delete." << endl;
free(ptr);
}
};
#endif //MEMORYMANAGER_POINT_H