Commit 002018aa authored by BRENO RILHO LEMOS's avatar BRENO RILHO LEMOS

Function overloading example

parent cb4a3019
#include <iostream>
using namespace std;
void date(char *date); // REMEMBER: in C++, functions always need prototype!
void date(int month, int day, int year); // REMEMBER: in C++, functions always need prototype!
// Two date functions have different type arguments, so program will know which one to pick!
// Also work with different NUMBER of arguments! (which is also the case here)
void date(char *date) {
cout << date << "\n";
}
void date(int month, int day, int year) {
cout << month << "/" << day << "/" << year << "\n";
}
int main() {
date("8/11/2000");
date(8,11,2000);
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment