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

3Sum - Leetcode solution - How i turned into two-pointer approach?

  class Solution {     public List < List < Integer >> threeSum ( int [] nums ) {         Arrays . sort (nums); // first sort...