ExamVeda
Login
Home
Standard Template Library (STL) in C plus plus
?

What will be the output of the following C++ code?
#include <typeinfo>
#include <iostream>
using namespace std;
class shape
{
    public:
    virtual void myvirtualfunc() const {}
};
class mytriangle: public shape
{
    public:
    virtual void myvirtualfunc() const
    {   
    };
};
int main()
{
    shape shape_instance;
    shape &ref_shape = shape_instance;
    try 
    {
        mytriangle &ref_mytriangle = dynamic_cast(ref_shape);
    }
    catch (bad_cast) 
    {
        cout << "Caught: bad_cast exception\n";
    }
    return 0;
}

Answer & Solution
Correct Answer: Option C
Let's discuss the solution. Join the discussion
Examveda
Question posted by Examveda
Community

Join the Discussion

No comments yet Be the first to discuss this question.