What will be the result of code execution?
#include <stdio.h>

class Grand {
    public:
        virtual void Count() = 0;
};
class ParentFather : virtual public  Grand{
    public: 
        virtual void Count() { printf("%d", 1); }
        virtual void Count(int i) { printf("%d", i + 1); }
}; 
class ParentMother : virtual public Grand{    
    public:
        virtual void Count() { printf("%d", 2); }
        virtual void Count(int i) { printf("%d", i + 2); }
}; 
class Child : public ParentFather, public ParentMother {    
        void Count() { printf("%d", 3); }
        void Count(int i) { printf("%d", i + 3); }
};
int main()
{
    ParentFather *grand = new Child;
    ParentMother *mother = dynamic_cast<ParentMother*>(grand);
    mother->Count(25.9);
    return 0;
}
Explanation
Get an explanation when it's available:

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Cosmo
Sign Up Now
or Subscribe for future quizzes