What is the result of the given code fragment? #include class A{ public: A(){f(); } virtual~A(){} public: virtual void f() const {std::cout<<1;} class B : public A{ public: B(){f();} private: virtual void f() const{std::cout<<2;} } int main() { const A *a=new B; delete a; std::cout<





Answer Detail

What is the result of the given code fragment? #include <stdio.h> class A{ public: A(){f(); } virtual~A(){} public: virtual void f() const {std::cout<<1;} class B: public A{ public: B(){f();} private: virtual void f() const{std::cout<<2;} } int main() { const A *a=new B; delete a; std::cout<<std::endl; return 0; }

Leave a Comment

Your email address will not be published. Required fields are marked *