jeudi 2 août 2018

Forward declared enum, default value in .h

Types.h

enum MyEnum : int8
{
    invalid = -1,
    valid = 0,
}

class TestClass 
{ ... default stuff ...}

MyOtherHeader.h

enum MyEnum : int8;
class TestClass;

class MyClass
{
    MyEnum Val = -1;
    TestClass* MyObj= nullptr;
}

Why can we assign null to a forward declare Class Pointer, but can't assign a value of the defined underlying type of the enum to a forwarded declared one?

Shouldn't the compiler be able to "deduce" that properly?

Aucun commentaire:

Enregistrer un commentaire