mercredi 17 avril 2019

Operator overloading is happening in this question but the number of arguments and type is same

The following code should generate compilation error according to me. Because I think the compiler might be confused to know which foo() to call.

#include <iostream> 

typedef long long ll;

void foo(unsigned ll) {
    std::cout << "1";
}

void foo(unsigned long long) {
    std::cout << "2";
}

int main() {
    foo(2ull);
}

Aucun commentaire:

Enregistrer un commentaire