Re: Looking for intuitive explanation of complex template class!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
On 5/16/2013 10:01 AM, Haircuts Are Important wrote:
I found an error in the posted code also. I'll work on deciphering
this today.
With the two changes, the posted code should have been:
Thanks,
class A:public B::C<D,const E,const F>
{
public:
A():B::C<D, const E, const F> (&D::G){}
};
template<class T, class p1, class p2>
class C: public H<T>
{
protected:
typedef void (T::*I)(p1,p2);
public:
C (I M):J(M){}
};
template <class T>
class H
{
protected:
typedef std::K<int,T*>L;
typedef typename std::K<int, T*>::iterator M;
};
class D:public N<O, P>
{
virtual void Q (const P& R)
{
W->X(R.S);
}
};
template <class T, class p1>
class N
{
T* W;
virtual void X (const p1& U) = 0;
};
Does it compile? How do you use class A? I can see that 'N' is used in
'D', 'D' is used in 'A', 'H' is instantiated as the base of 'C', and 'C'
is the base of 'A' (probably from the 'B' namespace), but it's unclear
what are 'E' and 'F'. Is class A is not a class but a template, maybe?
Again, how do you use it?
And, the answer is still the same, the 'W' is a data member of the 'N'
class template. It has the type "pointer to a 'T' (the first template
argument)", so whatever you instantiate the 'N' with, will be the type
of the object to which 'W' is supposed to point. So, when it's
dereferences in 'D::Q', the presumption is that the type 'O' (since
that's the first argument to the 'N' instance from which 'D' inherits)
contains a member 'X' that can be called like a function (with a single
argument of some type (same as the 'S' member of 'P')
If something is unclear, try to formulate and ask specific questions
(instead of "just explain everything to me", since that usually takes a
lifetime and still doesn't achieve the expected result in many cases).
V
--
I do not respond to top-posted replies, please don't ask