I can't figure out why I get error for the code below.
The instances of object A will be pushed into a vector (vectorA.push_back(A a)) continuously. So sometimes, vectorA needs to be reallocated; the destructor will be called, which is where the destructor of A gets called, then the error message appears.
class A
{
    long filePos;
    union {
        Recording* recording;
        UINT64 timeStamp;
    };
public:
    inline A(long fpos, UINT64 ts) : filePos(fpos), timeStamp(ts) {}
    ~A()
    {
        if (getDetailedType() == RECORDING_TYPE)
            if (recording)
                delete recording; // error: scalar deleting destructor ???
    }
    inline short getDetailedType() const { return (short)(timeStamp % 5); }
    A(const A& edi)
    {
        filePos = edi.filePos;
        if (getDetailedType() == RECORDING_INFO)
            recording = edi.recording;
        else
            timeStamp = edi.timeStamp;
    }
}
class Recording : protected RECORDINGS
{
    UINT64 timestamp;
    float scalar;
public:
    ~Recording() // with or without this dtor, got same error
    {
    }
    inline Recording()
    {
        timestamp = 0;
        scalar = 2.0;
        time = 0;
        rate = 30;
        type = 1;
        side = 1;
    }
}
typedef struct
{
    UINT32 time;
    float rate;
    int type;
    int side;
} RECORDINGS;
 
     
     
     
    