mardi 31 mai 2016

Circularity when using base and derived class as arrays in both

I am trying so make a class which holds a arbitrary value as specified in NBT format. It is a kind of json, but more advanced.

So, I make a class which holds a ListValue(a value without a name) and another one which holds a Value(with name). In the derived class, I lift = operator from base

using ListValue::operator=;

In a third file I have two usings:

using CompoundData = std::vector<Value>;
using ListData = std::vector<ListValue>;

ListValue has a private member as:

union ValueHolder
{
    Byte vByte;
    Short vShort;
    Int vInt;
    Long vLong;
    Float vFloat;
    Double vDouble;
    String* pString;
    CompoundData* pCompound;
} mData;

(I'll add ListData* later)

The problem is I have absolutely no idea how how to include all these headers so it will work with the circularity. I tried several forward declarations and containers as vector or vector with smart pointers for breaking it, but nothing worked for me.

I would be very very grateful if you could help me to give me a(n) idea / solution for my code. Thank you very much.

Aucun commentaire:

Enregistrer un commentaire