What are Virtual Methods?

The Virtual Modifier is used to mark that a method\property(ect) can be modified in a derived class by using the override modifier. Example: class A { public virtual void Foo() //DoStuff For A } class B : A { public override void Foo() //DoStuff For B //now call the base to do the stuff for … Read more

virtual inheritance [duplicate]

Virtual inheritance is used to solve the DDD problem (Dreadful Diamond on Derivation). Look at the following example, where you have two classes that inherit from the same base class: class Base { public: virtual void Ambig(); }; class C : public Base { public: //… }; class D : public Base { public: //… … Read more

Writing a Virtual Printer in .NET [closed]

Did exactly what you are asking using the Github project: Microsoft/Windows-driver-samples/print/XPSDrvSmpl https://github.com/Microsoft/Windows-driver-samples/tree/master/print/XPSDrvSmpl Installer: http://wixtoolset.org/ Application: Listen to internal port Flow: Install printer and application from a single installer. User prints something with your driver while the application listens to the internal port. When data is sent the application picks it up. This is for XPS, … Read more

C++ What is the purpose of casting to void? [duplicate]

Multiple purposes depending on what you cast Marking your intention to the compiler that an expression that is entirely a no-op is intended as written (for inhibiting warnings, for example) Marking your intention to to the compiler and programmer that the result of something is ignored (the result of a function call, for example) In … Read more

Is it OK to call abstract method from constructor in Java? [duplicate]

This code demonstrates why you should never call an abstract method, or any other overridable method, from a constructor: abstract class Super { Super() { doSubStuff(); } abstract void doSubStuff(); } class Sub extends Super { String s = “Hello world”; void doSubStuff() { System.out.println(s); } } public static void main(String[] args) { new Sub(); … Read more

Calling virtual function from destructor

I am going to go against the flow here… but first, I must assume that your PublicBase destructor is virtual, as otherwise the Derived destructor will never be called. It is usually not a good idea to call a virtual function from a constructor/destructor The reason for this is that dynamic dispatch is strange during … Read more