Skip to content
Quiz · Classes and OOP · lesson 14 of 15

Quiz — dynamic_cast

What does the program print?

C++
#include <iostream>

struct Shape {
    virtual int sides() const { return 0; }
};
struct Circle : public Shape {};
struct Square : public Shape {};
int main() {
    Square sq;
    Shape* p = &sq;
    std::cout << (dynamic_cast<Circle*>(p) == nullptr) << '\n';
}

Subscribe to take the course

The course is free. Sign in with Telegram and subscribe to the channel to open every lesson.

Sign in another way