Pages

Sunday, May 11, 2025

Function Overloading in OOPs

 #include <iostream>

using namespace std;

class Print {
public:
    void show(int x) {
        cout << "int: " << x << endl;
    }    

    void show(string str) {
        cout << "string: " << str << endl;
    }

};

int main() {
    Print ob1;
    ob1.show(25);
    ob1.show("apna college");

    return 0;
}

OUTPUT:-
int: 25 string: apna college

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...