About 214,000 results
Open links in new tab
  1. Why does returning a virtual class *by value* in C++ alter the v …

    Aug 6, 2020 · In the following code I return a derived class CDerived by-value from a function returning its base class, CBase. For example purposes, CDerived contains a _number field, …

  2. Any way to use base constructor in derived class? - Stack Overflow

    Dec 8, 2016 · CDerived::CDerived(LPCTSTR pszArg1, LPCTSTR pszArg2, LPCTSTR pszArg3) : CBase(pszArg1, pszArg2, pszArg3) { } But that seems like a lot of typing, particularly if I plan …

  3. How to call virtual function of derived class through base class …

    CBase *pBase = new CChild; pBase->vfunc(); virtual function calls are resolved dynamically on pointers & references (unless you call the method explicitly, like you did). Which means it …

  4. How to publicly inherit from a base class but make some of public ...

    For example, class Base has two public methods: foo() and bar(). Class Derived is inherited from class Base. In class Derived, I want to make foo() public but bar() private. Is the following code …

  5. what's polymorphic type in C++? - Stack Overflow

    Sep 6, 2015 · I found in one article saying "static_cast is used for non-polymorphic type casting and dynamic_cast is used for polymorphic type casting". I understand that int and double are …

  6. How do I ensure assignability within this tree? - Stack Overflow

    Jul 6, 2009 · There is tree of classes rooted at CBase (single-inheritance). CSub is derived from CBase, and other classes derived from CBase or CSub, and CBase having virtual member …

  7. Align packages vertically in PlantUML - Stack Overflow

    BBase <|-- B1 BBase <|-- B2 BBase <|-- B3 } package "C" { CBase <|-- C1 CBase <|-- C2 CBase <|-- C3 } @enduml PlantUML renders the packages next to each other. This can get way too …

  8. Prevent class inheritance in C++ - Stack Overflow

    Feb 2, 2010 · To answer your question, you can't inherit from CBase because in virtual inheritance a derived class would need to have direct access to the class from which it was …

  9. Warning C4800: 'int' : forcing value to bool 'true' or 'false ...

    Sep 22, 2014 · id or MID_SYMBOL must be of type BOOL. which is just #define to int type in Windows. Your return value is BOOL and it is converted into bool (true or false ).

  10. c++ - Derived class vtable corrupted? - Stack Overflow

    Jul 13, 2016 · Need help in root causing a vtable corruption issue(not sure if that’s what is happening). Here is the very simplified version of the code. class CBase { public: CBase() …