Hey guys I trying to make abstract base class and I made this. It working without any issues, but im not sure if I can use operator new like this in declaration. I thought that I can use operator new just in constructor but it looks like that I can use operator new like this:
#include <iostream>
using std::cout;
class abs
{
private:
int* x = new int;
int* y = new int;
protected:
static int count;
public:
virtual void show() = 0;
abs() { *x = 0; *y = 1; count++; cout << "Vytvoren objekt tridy ABS: " << count << "\n"; };
virtual ~abs() { delete x; delete y; count--; cout << "Objekt tridy ABS zrusen: " << count << "\n"; };
};
class one : public abs
{
private:
int* z = new int;
public:
virtual void show();
one();
virtual ~one() { delete z; count--; cout << "Zrusen objekt tridy ONE: " << count << "\n"; };
};
#endif
Is it possible to use it like this or is it wrong?