[ create a new paste ] login | about

Link: http://codepad.org/RXe3ym0u    [ raw code | output | fork ]

GManNickG - C++, pasted on Oct 26:
template <typename T, T V>
struct rob
{
    rob()
    {
        value = V;
    }

    static T value;
};

template<typename T, T V>
T rob<T, V>::value;

struct A
{
private:
    void f()
    {
        std::cout << "proof!" << std::endl;
    }
};

template class rob<void(A::*)(), &A::f>;

int main()
{
    A a;
    rob<void(A::*)(), &A::f>();

    (a.*rob<void(A::*)(), &A::f>::value)();
}


Output:
1
2
3
In function 'int main()':
Line 18: error: 'void A::f()' is private
compilation terminated due to -Wfatal-errors.


Create a new paste based on this one


Comments: