int i is not a tyoe so you can't use it ro specialize a template. Neither is 4. SO these lines are just wrong:
template <int i> Handle( void * p) {}
template <> Handle<4>( void * p)
{ ... }
plus there is no object name.
Your class A has a Handle as a member. If it is a Handle<int>, then say so:
-
class A
-
{
-
Handle<int> v1;
-
};
-
If the Handle has a constructor, it will be called when an object of A is created. That will require a constructor on A to call the constructor on the Handle.
LIke this:
-
class Handle
-
{
-
public:
-
Handle(void*) {}
-
-
};
-
-
class A
-
{
-
//...
-
void* p;
-
public:
-
A() : v1(p) {}
-
-
Handle<int> v1;
-
-
};
-
int main()
-
{
-
-
A obj;
-
-
}
-
Finally, if this handle is for what I think it is, then there is one already set uop for you in the C/C++ HowTos in an article about Handle classes. Just copy out the template and off you go.