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;
}

Следи за CodeGalaxy

Мобильное приложение Beta

Get it on Google Play
Обратная Связь
Cosmo
Зарегистрируйся сейчас
или Подпишись на будущие тесты