By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,654 Members | 936 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,654 IT Pros & Developers. It's quick & easy.

Sticky problem with collection class

P: n/a
I was trying to put together a little utility generic collection class
like so:

template <class T>
class Collection
{
public:
Collection();
Collection(const Collection&);
Collection& operator= (const Collection&);
virtual ~Collection();

size_t size() const ;
bool isBOF() const ;
bool isEOF() const ;
void goToFirst() ;
void goToLast();
moveNext();
movePrev();
T item();
T item(size_t) ; //throws array bounds exception

protected:
vector<Tm_col ; // <- dosen't work (obviously ;-) )
}
There are two problems here:

1). I don't want to use specialized templates - because I want the class
to be a truly generic container
2). I want to be able to also handle a collection of pointers (stored
as smart ptrs) - if need be
-- Any ideas on how to store the various types (including pointers?)

Nov 7 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a


Bit Byte wrote:
I was trying to put together a little utility generic collection class
like so:

template <class T>
class Collection
{
public:
Collection();
Collection(const Collection&);
Collection& operator= (const Collection&);
virtual ~Collection();

size_t size() const ;
bool isBOF() const ;
bool isEOF() const ;
void goToFirst() ;
void goToLast();
moveNext();
movePrev();
T item();
T item(size_t) ; //throws array bounds exception

protected:
vector<Tm_col ; // <- dosen't work (obviously ;-) )
}
There are two problems here:

1). I don't want to use specialized templates - because I want the class
to be a truly generic container
2). I want to be able to also handle a collection of pointers (stored
as smart ptrs) - if need be
-- Any ideas on how to store the various types (including pointers?)
Correction - the move* methods are of type void (before anyone points
that out)

Nov 7 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.