Medium
A derived-class function with the same name as base overloads
What happens when this program is compiled?
main.cpp
#include <iostream>
#include <string>
struct Base {
void greet() { std::cout << "Base::greet()\n"; }
void greet(int n) { std::cout << "Base::greet(int)\n"; }
};
struct Derived : Base {
void greet(const std::string& name) { std::cout << "Derived::greet(string)\n"; }
};
int main() {
Derived d;
d.greet(5);
}53 of 117 in C++