mlimber said:
Do you have experience in object-oriented design? _TC++PL_ and _MC++D_
will teach you *how* to do things in C++, but they don't concentrate on
*what* to do and *when* to do it. For the what and when, check out, for
instance, _Design Patterns: Elements of Reusable Object-Oriented
Software_ by Gamma et al. As I mentioned, _MC++D_ builds on _Design
Patterns_, and without understanding something about design patterns
and how they can be used, _MC++D_ won't be as useful.
Cheers! --M
Well, I think I have a general idea about design patterns except I just
don't have enough experience with it. I mean, I understand classes,
inheritence, multiple inheritence, etc... I think pretty well(atleast
decently) and I know for the most part how to use them to do things but I
guess its because I haven't done virtually any real programming in a very
long time that my brain just isn't able to see the big picture because its
forgotten to much of the details.
Like now my problem seems to be getting the semantics right for doing my
template stuff(see my other threads)... I'm just not understanding how the
template semantics work out. I can easily understand something like
template <class I>
class J
{
};
means.. if I do J<some type> then it just replaces all instances of I with
that type as if I had typed it in directly(atleast that is what I think...
maybe there is more).
But if I do something like
template <unsigned int I, unsigned int J, typename T>
struct Node
{
enum {i = I};
enum {j = J};
typedef T Class;
};
I understand I can do something like Node<1,4,some class> but I don't have a
clue what that "object" is. I "know" I can access the "fields" of that
"object" by using the scope such as Node<1,4,some class>::i should return 1.
It seems that the Node object just propagates a "meta container" through the
complication process and I can refer to it as a whole instead of having to
propagate the 3 pieces of data... so then I could do stuff like
Node<i,j,Node<a,b>> which propagates 4 pieces of information and through
recursion I could have it do as many as I want... all this seems to be
playing semantic games.
But I cannot understand for the life of me why something like
template <int i, typename T>
struct RT
{
};
template <int I, int J, typename T>
struct RT< Node<I,J,T>::i, Node<I,J,T> > : public Node<I,J,T>::Class
{
};
doesn't work. or even if I did
template <int I, int J, typename T>
struct RT< Node<I,J,T>::i, Node<I,J,T> > : public T::Class
{
};
It seems that the public part should be exactly the same(I guess it is
though).
I don't understand why, though, the
struct RT< Node<I,J,T>::i, ....
gives me some stupid error about it not being a simple type or something.
Isn't Node<I,J,T>::i just some literal value(an int)? and so shouldn't be
equivilent to just typing an int there?
Things like this I am confused on. I guess its cause I don't know the inner
works of templates and just know the very basics of them. But I can't seem
to find anything that discusses things like this.
Almost everything I find just show simple examples of how to do stupid stuff
with templates that does not talk about how templates actually work and what
the syntax and semantics are. i.e., the info I need so I can fix my
problem.
Anyways, I guess I just probably need to do some reading... probably the
strousoup or whatever book you mentioned. I'll try to get my hands on one
and see.
Thanks,
Jon