Re: Template class parameter
- From: "Igor Tandetnik" <itandetnik@xxxxxxxx>
- Date: Thu, 15 Nov 2007 23:19:49 -0500
"George" <George@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:C587EFA2-6680-40DE-A7DC-ACBDCBF9123A@xxxxxxxxxxxxx
Sometimes a template class is defined to have only parameter and no
type (e.g. class something) information. Like the below sample. My
question is, why define template class in this way (e.g. I can
implement in an alternative way to put the parameter into
constructor)?
For example:
template <size_t sz>
class FixedArray {
int a[sz];
public:
// Allows running STL algorithms over fixed array
int* begin();
int* end();
};
Try doing this with a parameter passed to constructor, without a heap
allocation.
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925
.
- Prev by Date: Re: editor outlining bug (spurious semicolon)
- Next by Date: Re: address of constant
- Previous by thread: editor outlining bug (spurious semicolon)
- Next by thread: Re: Template class parameter
- Index(es):
Relevant Pages
|