search for: childwithinfo

Displaying 1 result from an estimated 1 matches for "childwithinfo".

2017 Jun 28
2
Multiple Inheritance with dyn_cast
...Here’s my sample code which doesn’t work: ``` struct Base { void *ptr; bool hasInfo; }; struct Info { int size; static bool classof(const Base *b) { return b->hasInfo; }; }; struct Child : public Base { Child() { this->ptr = this; this->hasInfo = false; } }; struct ChildWithInfo : public Base, public Info { ChildWithInfo() { this->ptr = this; this->hasInfo = true; this->size = 10; } }; int main() { Base *c = new Child(); Base *i = new ChildWithInfo(); try { if (Info *inf = llvm::dyn_cast<Info>(c)) { throw std::string("Ca...