#include <iostream> using namespace std; template<int a> class T{ namespace A{ int f1(); int f2(); } namespace B{ int f1(); int f2(); } public: void test(); }; template<int a> void T<a>::test(){cout<<a<<A::f1()<<A::f2()<<B::f1()<<B::f2();} template<int a> int T<a>::A::f1(){return a+1;} template<int a> int T<a>::A::f2(){return a-1;} template<int a> int T<a>::B::f1(){return a*2;} template<int a> int T<a>::B::f2(){return a*3;} int main() { T<2> t; t.test(); return 0; }
Standard input is empty
prog.cpp:5:2: error: expected unqualified-id before 'namespace'
namespace A{
^
prog.cpp:9:2: error: expected unqualified-id before 'namespace'
namespace B{
^
prog.cpp: In member function 'void T<a>::test()':
prog.cpp:17:44: error: 'A' has not been declared
template<int a> void T<a>::test(){cout<<a<<A::f1()<<A::f2()<<B::f1()<<B::f2();}
^
prog.cpp:17:53: error: 'A' has not been declared
template<int a> void T<a>::test(){cout<<a<<A::f1()<<A::f2()<<B::f1()<<B::f2();}
^
prog.cpp:17:62: error: 'B' has not been declared
template<int a> void T<a>::test(){cout<<a<<A::f1()<<A::f2()<<B::f1()<<B::f2();}
^
prog.cpp:17:71: error: 'B' has not been declared
template<int a> void T<a>::test(){cout<<a<<A::f1()<<A::f2()<<B::f1()<<B::f2();}
^
prog.cpp: At global scope:
prog.cpp:18:21: error: 'T<a>::A' is not a type
template<int a> int T<a>::A::f1(){return a+1;}
^
prog.cpp:18:33: error: invalid use of dependent type 'typename T<a>::A'
template<int a> int T<a>::A::f1(){return a+1;}
^
prog.cpp:19:21: error: 'T<a>::A' is not a type
template<int a> int T<a>::A::f2(){return a-1;}
^
prog.cpp:19:33: error: invalid use of dependent type 'typename T<a>::A'
template<int a> int T<a>::A::f2(){return a-1;}
^
prog.cpp:20:21: error: 'T<a>::B' is not a type
template<int a> int T<a>::B::f1(){return a*2;}
^
prog.cpp:20:33: error: invalid use of dependent type 'typename T<a>::B'
template<int a> int T<a>::B::f1(){return a*2;}
^
prog.cpp:21:21: error: 'T<a>::B' is not a type
template<int a> int T<a>::B::f2(){return a*3;}
^
prog.cpp:21:33: error: invalid use of dependent type 'typename T<a>::B'
template<int a> int T<a>::B::f2(){return a*3;}
^
Standard output is empty