samedi 23 mars 2019

c++ Template Inheritance With Pure Virtual Functions

template<typename PacketTypes>
class PacketFormatAbstractor
{
public:
    virtual ~PacketFormatAbstractor() {};

    virtual size_t PacketHeaderSize() = 0;
    virtual size_t PacketSize(PacketTypes type) = 0;
    //...
};

template<typename PacketTypes>
class APureBase : public AParant, public PacketFormatAbstractor<PacketTypes>
{
public:
    //some pure vurtual Functions
}

namespace ConcretePacketTypes {
    enum ConcretePacketTypes {
        type1,
        type2,
        type3
    };
};

class Deriver : public AParant, public PacketFormatAbstractor<enum ConcretePacketTypes::ConcretePacketTypes>
{
public:
    //All functions implemented, no pure virtual left
}

The above code causes the compile error " error C2653: 'ConcretePacketTypes': is not a class or namespace name"

Any ideas how to fix this error, I have tried a bunch of things and can not seem to appease the compiler?

Aucun commentaire:

Enregistrer un commentaire