#include &lt;iostream&gt;    using namespace std;    struct A     &#123;        virtual void f&#40;&#41;          &#123;             cout &lt;&lt; &quot;Class A&quot; &lt;&lt; endl;         &#125;    &#125;;    struct B : A     &#123;        virtual void f&#40;&#41;         &#123;             cout &lt;&lt; &quot;Class B&quot; &lt;&lt; endl;        &#125;    &#125;;    struct C : A     &#123;        virtual void f&#40;&#41;         &#123;            cout &lt;&lt; &quot;Class C&quot; &lt;&lt; endl;         &#125;    &#125;;    void f&#40;A* arg&#41;     &#123;        B* bp = dynamic_cast&lt;B*&gt;&#40;arg&#41;;        C* cp = dynamic_cast&lt;C*&gt;&#40;arg&#41;;        if &#40;bp&#41;            bp -&gt; f&#40;&#41;;        else if &#40;cp&#41;            cp -&gt; f&#40;&#41;;        else            arg -&gt; f&#40;&#41;;      &#125;;    int main&#40;&#41;     &#123;        A aobj;        C cobj;        A* ap = &amp;cobj;        A* ap2 = &amp;aobj;        f&#40;ap&#41;;        f&#40;ap2&#41;;    &#125;
A. Class C
B. Class A
C. Both a & b
D. None of the mentioned
Answer:A
#include &lt;iostream&gt;    using namespace std;    struct A     &#123;        virtual void f&#40;&#41;          &#123;             cout &lt;&lt; &quot;Class A&quot; &lt;&lt; endl;         &#125;    &#125;;    struct B : A     &#123;        virtual void f&#40;&#41;         &#123;             cout &lt;&lt; &quot;Class B&quot; &lt;&lt; endl;        &#125;    &#125;;    struct C : A     &#123;        virtual void f&#40;&#41;         &#123;            cout &lt;&lt; &quot;Class C&quot; &lt;&lt; endl;         &#125;    &#125;;    void f&#40;A* arg&#41;     &#123;        B* bp = dynamic_cast&lt;B*&gt;&#40;arg&#41;;        C* cp = dynamic_cast&lt;C*&gt;&#40;arg&#41;;        if &#40;bp&#41;            bp -&gt; f&#40;&#41;;        else if &#40;cp&#41;            cp -&gt; f&#40;&#41;;        else            arg -&gt; f&#40;&#41;;      &#125;;    int main&#40;&#41;     &#123;        A aobj;        C cobj;        A* ap = &amp;cobj;        A* ap2 = &amp;aobj;        f&#40;ap&#41;;        f&#40;ap2&#41;;    &#125;
A. Class C B. Class A C. Both a & b D. None of the mentioned
Explanation:In this program, We applied the dynamic casting to structure and produced the output.