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

Stack using Linked List – Partial (University Exam Topic)

 #include <iostream> using namespace std; struct Node {     int data;     Node* next; }; class Stack {     Node* top; public:     Stac...