Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Sepples quiz

Name: Anonymous 2012-08-31 23:49

What does it output?

using namespace std;
#include <iostream>
int main() {
    try {
        void *(*fp)(const int * const);
        throw fp;
    }
    catch(void *(*e)(int *)) {
        cout << "A" << endl;
    }
    catch(void *(*e)(int * const)) {
        cout << "B" << endl;
    }
    catch(void *(*e)(const int *)) {
        cout << "C" << endl;
    }
    catch(void *(*e)(const int * const)) {
        cout << "D" << endl;
    }
    return 0;
}

Name: Anonymous 2012-09-01 0:03

At first i thought it would be A because it's the most generic function and it has a compatibile-looking signature but then i ran it and it was C because there's no implicit dropping of the const qualifier

The red herring here is that post-declaration const is pretty meaningless outside of member functions afaict

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List