Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The snippet is very low quality, it is littered with uncompilable code. No repro once I fixed all the mistakes.</p> <pre class="lang-c prettyprint-override"><code>#include "stdafx.h" #include &lt;iostream&gt; using namespace System; //C++ -native classes class NativeFoo { public: NativeFoo(): tested(true){} virtual void execute() { std::cout &lt;&lt; "Native Foo" &lt;&lt; std::endl; } protected: bool tested; }; class NativeBarA :NativeFoo { public: NativeBarA(): NativeFoo(){} void execute() { std::cout &lt;&lt; "Native Bar A" &lt;&lt; std::endl; } }; class NativeBarB : public NativeFoo { public: NativeBarB() :NativeFoo(){} void execute() { std::cout &lt;&lt; "Native Bar B" &lt;&lt; std::endl; } }; //CLI interface public interface class IExecutable { public: void Execute(); }; //C++-CLI classes public ref class ManagedFoo: public IExecutable { private: NativeFoo* impl; public: ManagedFoo(): impl(NULL) { impl = new NativeFoo(); } virtual void Execute() { impl-&gt;execute(); } }; public ref class ManagedBarA: public ManagedFoo { private: NativeBarA* impl; public: ManagedBarA(): ManagedFoo(), impl(NULL) { impl = new NativeBarA(); } virtual void __clrcall Execute() override { impl-&gt;execute(); } }; public ref class ManagedBarB: public ManagedFoo { private: NativeBarB* impl; public: ManagedBarB(): ManagedFoo(), impl(NULL) { impl = new NativeBarB(); } virtual void __clrcall Execute() override { impl-&gt;execute(); } }; //Calling code [STAThread] int main(array&lt;System::String ^&gt; ^args) { ManagedFoo^ mfoo = gcnew ManagedFoo(); ManagedBarA^ mbarA = gcnew ManagedBarA(); ManagedBarB^ mbarB = gcnew ManagedBarB(); mfoo-&gt;Execute(); //OK mbarA-&gt;Execute(); //Fine mbarB-&gt;Execute(); //Fine } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload