Pages

Friday, May 16, 2025

Predicting the output of friend function and class in OOPs - 02

 #include <iostream>

using namespace std;

class Base
{
public:
    virtual void print() {
        cout << "Base\n";
    }
};

class Derived : public Base {
public:
    void print() {
        cout << "Derived\n";
    }


};
int main() {
    Base *b = new Derived();
    b->print();

    delete b;
    return 0;
}

No comments:

Post a Comment

how to become red on codeforces by Errichto Algorithms | explained simply in a blog

 Yes. I found an available transcript of the video and summarized it simply. The video is “How To Become Red Coder? (codeforces.com)” by Err...