Перейти к содержимому
Тест · Классы и ООП · урок 11 из 13

Тест — dynamic_cast

Что выведет программа?

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