当我编译这个时,我收到编译错误和警告。
#include <iostream>
struct {
uint8_t m_data;
int size;
} BufferCustom;
class MyClass
{
private:
int x, y;
const int CONST_BUFFER_SIZE = 10;
struct BufferCustom *m_BufferPtr;
public:
MyClass(int xx, int yy) : x(xx), y(yy)
{
m_BufferPtr = new struct BufferCustom[CONST_BUFFER_SIZE];
}
virtual ~MyClass() {
if (m_BufferPtr){
delete [] m_BufferPtr;
m_BufferPtr = nullptr;
}
}
// user defined copy constructor
MyClass(const MyClass& rhs)
: x{ rhs.x }, y{ rhs.y } // initialize members with other object's // members
{
std::cout << …Run Code Online (Sandbox Code Playgroud)