Which of the following lines will cause compilation errors:
class Base {
    public:
        void method1();
    protected:
        void method2();
    private:
        void method3();
};

class Child : public Base {
    protected:
        void method1() { }
        void method2() { }
        void method3() { }
};

int main() { 
    Base* base = new Child();
    base->method1();         // 1
    base->method2();         // 2
    base->method3();         // 3
    return 0; 
}

Follow CodeGalaxy

Mobile Beta

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