class Foo { int a;public: Foo(int i) : a(i) {} template<typename T> auto foo() -> decltype(a) { return a; } auto foo() -> decltype(a) { return a; }}; int main() { Foo f(0); f.foo(); // works fine f.foo<float>(); // error}
Standard input is empty
prog.cpp: In function 'int main()': prog.cpp:2:9: error: 'int Foo::a' is private prog.cpp:17:18: error: within this context prog.cpp:2:9: error: 'int Foo::a' is private prog.cpp:17:18: error: within this context
Standard output is empty
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!