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

3917. Count Indices With Opposite Parity (Brute Force) O(n2) + Optimized Solution O(n) + tips LEETCODE WEEKLY 500

  class Solution {     public int [] countOppositeParity ( int [] nums ) {          // approach 1 - checks every pair         int n = n...