I am trying to do some simple polymorphic code, but when calling parent objects, the passed pointer dereferences to an empty data structure. This is something that should "just work", but it isn't.
However, when I make a Command* command = new DefineObject(data). and _data.init = true but _data.object = false (so it falls back on the parent object's definition) I get out:
Print error
Because the _data structure has empty members (which I can check in gdb). What the heck is going on? For some reason a Definition* const pointer dereferencing _data from a DefineObject* const pointer is empty even though the classes have the same memory structure? (There's some more to format than what I included, but I wanted to keep the problem simpler)
What's happening is that there's two objects named '_data' in each DefineObject. One is DefineObject::_data, and the other is Definition::_data. When you're constructing DefineObject, you're only initializing DefineObject::_data. The other one is left with garbage.
Either remove one of the objects -- preferably DefineObject::_data, while making the other one protected -- or call the base constructor in DefineObject::DefineObject().
PS: Oh, and please leave less spacing in the code. It's right there on the high end of "unreadable mess", but I think if you apply yourself, you get it all the way up to "clusterfuck".