inheritance question 
Author Message
 inheritance question

class Cylinder : public Circle
{

Quote:
}

this is a simple example that I understand. But what does the following mean

class CProduct : public CCommand<CAccessor<CProductAccessor> >
{

Quote:
}

In particular what does the <      <      >> do?
Is this some sort of template syntax?
Are these parameters?


Tue, 06 May 2003 03:00:00 GMT  
 inheritance question

Quote:

> class Cylinder : public Circle
> {
> }

> this is a simple example that I understand. But what does the following mean

> class CProduct : public CCommand<CAccessor<CProductAccessor> >
> {
> }

> In particular what does the <      <      >> do?
> Is this some sort of template syntax?

Yes, exactly.  CAccessor is a template class, and CProductAccessor is
its argument.  Thus CAccessor<CProductAccessor> is a type, which
itself is the template argument passed to the CCommand template

Thus, CProduct inherits from a template class, whose template argument
is another template class.

Quote:
> Are these parameters?

Yes, though I prefer to distinguish between arguments and parameters.  

        template <class T> class A{};

        A<int> a;

In the above code, I'd say 'T' is the parameter, (used in a
declaration) and int is the argument (used when instantiating the
template class).  Still, different people may use the terms
interchangeably.

--
Chris



Tue, 06 May 2003 03:00:00 GMT  
 inheritance question

Quote:
> > Are these parameters?

> Yes, though I prefer to distinguish between arguments and parameters.

>         template <class T> class A{};

>         A<int> a;

> In the above code, I'd say 'T' is the parameter, (used in a
> declaration) and int is the argument (used when instantiating the
> template class).  Still, different people may use the terms
> interchangeably.

> --
> Chris

So for B to inherit from A would go like:

class B : public A<int>

and instead of passing a primitive data type if I passed into A a templet
class C This is what it would look like

class B : public A<C<int>>

to the extream would be to change int to class D and then we would have

classB : public A<C<D>>

Do I have this figured out or am I still off a bit?



Tue, 06 May 2003 03:00:00 GMT  
 inheritance question
-- below...

--
Reginald Blue                   | Opinions expressed here do not
Natural Language Understanding  | necessarily represent those of
Unisys Corporation              | my employer.
--------------------------------+-------------------------------

NL technology,speech application| My email address is wrong, you
development training, see:      | need to remove the obvious.
http://www.speechdepot.com/     +-------------------------------


Quote:

> So for B to inherit from A would go like:

> class B : public A<int>

> and instead of passing a primitive data type if I passed into A a templet
> class C This is what it would look like

> class B : public A<C<int>>

> to the extream would be to change int to class D and then we would have

> classB : public A<C<D>>

> Do I have this figured out or am I still off a bit?

-- No, that's pretty much it.  There are two things however:

1.  Amazingly, that last example could be:

class B : public A<C<B> >

and it would actually work.  How the compiler actually figures that out
eludes me, but...

2.  Don't do:

class B : public A<C<int>>

do

class B : public A<C<int> >

(note the extra space there between the two '>')

Reason?  The C++ parser interprets ">>" as a shift operator instead of as if
it were two of ">" those.



Tue, 06 May 2003 03:00:00 GMT  
 inheritance question

Quote:
> > Do I have this figured out or am I still off a bit?

> -- No, that's pretty much it.  There are two things however:

> 1.  Amazingly, that last example could be:

> class B : public A<C<B> >

> and it would actually work.  How the compiler actually figures that out
> eludes me, but...

> 2.  Don't do:

> class B : public A<C<int>>

> do

> class B : public A<C<int> >

> (note the extra space there between the two '>')

> Reason?  The C++ parser interprets ">>" as a shift operator instead of as
if
> it were two of ">" those.

Thanks that probably saved a couple of days of banging my head on the wall.


Tue, 06 May 2003 03:00:00 GMT  
 inheritance question

Quote:

> So for B to inherit from A would go like:

> class B : public A<int>

Yes.

Quote:
> and instead of passing a primitive data type if I passed into A a templet
> class C This is what it would look like

> class B : public A<C<int>>

Almost.  You must put a space between the closing >> or it will apper
to be the right-shift operator.

It should be like this:

        class B : public A<C<int> >

Quote:
> to the extream would be to change int to class D and then we would have

> classB : public A<C<D>>

> Do I have this figured out or am I still off a bit?

Looks like you got it.  (Except for the space. :)

--
Chris



Tue, 06 May 2003 03:00:00 GMT  
 inheritance question
Thanks

Quote:

> > So for B to inherit from A would go like:

> > class B : public A<int>

> Yes.

> > and instead of passing a primitive data type if I passed into A a
templet
> > class C This is what it would look like

> > class B : public A<C<int>>

> Almost.  You must put a space between the closing >> or it will apper
> to be the right-shift operator.

> It should be like this:

>         class B : public A<C<int> >

> > to the extream would be to change int to class D and then we would have

> > classB : public A<C<D>>

> > Do I have this figured out or am I still off a bit?

> Looks like you got it.  (Except for the space. :)

> --
> Chris



Tue, 06 May 2003 03:00:00 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. Inheritance Question

2. Inheritance question

3. Inheritance question...

4. Inheritance question

5. WinForm Event Inheritance Question

6. Events and Inheritance Question

7. ATL - inheritance question

8. newbie inheritance question

9. Class Inheritance question

10. Interface & Implementation inheritance question (ignore previous post)

11. Interface & Implementation inheritance question

12. virtual inheritance question

 

 
Powered by phpBB® Forum Software