"A definition for a static data member may be provided in a namespace scope
enclosing the definition of the static member's class template."
It means …
Is this correct…..
namespace N{
template<typename T>class A{
public:
static int x;
static int fun();
};
}
namespace N1{
template<class T>int A<T>::x=10; }
namespace N2{template<class T>int A<T>::fun(){return 10;} }
int main(){ return 0; }
According to the statement…whether my program is correct…
Otherwise…ca any one expalain this statement…With a program….
IT is the point from ISO Standard c++.chapter 14.5.1.3, point 1
If you check the standard you should see the example.
Your program is not correct because
did not use the template parameter T (and do you mean Ex instead of A?). Since you’re specializing a template, you should write
within the namespace N. (Not inside other namespaces like N1 or N2. It must be defined in the same namespace where Ex is declared.)