Video Coming Soon...
51: Function Overloading
Show how you can use the same name but have different arguments to create overloaded functions.
The Code
View Source file ex51.cpp Only
#include <fmt/core.h>
#include <string>
void do_thing(const std::string& as_string) {
fmt::println("a string: {}", as_string);
}
void do_thing(int i) {
fmt::println("an int: {}", i);
}
/*
int wont_work(int i) {
fmt::println("won't work?");
return 0;
}
float wont_work(int i) {
fmt::println("pretty sure.");
return 0.0f;
}
*/
int main(int argc, char* argv[]) {
do_thing("Zed");
do_thing(100);
}
The Breakdown
line of code- Description.
The Discussion
Blah blah.
Further Study
- Do this next.
Register for Learn C++ the Hard Way
Register to gain access to additional videos which demonstrate each exercise. Videos are priced to cover the cost of hosting.