Applying Object Oriented Programming Skills Examples
Applying Object Oriented Programming Skills Examples
OOP Examples
//1-Function overloading
#include <iostream>
using namespace std;
int plusFuncInt(int x, int y) {
return x + y;
}
double plusFuncDouble(double x, double y) {
return x + y;
}
int main() {
int myNum1 = plusFuncInt(8, 5);
double myNum2 = plusFuncDouble(4.3, 6.26);
cout << "Int: " << myNum1 << "\n";
cout << "Double: " << myNum2;
return 0;
}
//2-Inside Example
#include <iostream>
using namespace std;
int main() {
MyClass myObj; // Create an object of MyClass
myObj.myMethod(); // Call the method
return 0;
}
//3-Outside Example
#include <iostream>
using namespace std;