C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

how to put template class into container

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++)
View previous topic :: View next topic  
Author Message
海风
Guest





PostPosted: Thu Aug 17, 2006 9:10 am    Post subject: how to put template class into container Reply with quote



i have made a template class like this,
template< typename T>
class CStatus
{
public:
~CStatus(){}
void OnRender(CDisplay * pDisplay)
{
if ( C24Operator::operator_empty != _status)
{
_t->Render(pDisplay);

}
}
C24Operator::status_operator _status;
T _t;
public:
CStatus(C24Operator::status_operator st, T t)
{
_t =t;
_status = st;
}
private:
CStatus( const CStatus&);
CStatus operator=(const CStatus&);
};

Now i want to put its entities into a container ,for example a list
list<CStatus<>> alist is error, how should i do? thanks ahead
Back to top
Stefan Näwe
Guest





PostPosted: Thu Aug 17, 2006 9:10 am    Post subject: Re: how to put template class into container Reply with quote



海风 schrieb:
Quote:
i have made a template class like this,
template< typename T
class CStatus
{
public:
~CStatus(){}
void OnRender(CDisplay * pDisplay)
{
if ( C24Operator::operator_empty != _status)
{
_t->Render(pDisplay);

}
}
C24Operator::status_operator _status;
T _t;
public:
CStatus(C24Operator::status_operator st, T t)
{
_t =t;
_status = st;
}
private:
CStatus( const CStatus&);
CStatus operator=(const CStatus&);
};

Now i want to put its entities into a container ,for example a list
list<CStatus<>> alist is error, how should i do? thanks ahead


You can't declare a list of 'any CStatus'. You need a concrete type
e.g. CStatus<int>:

std::list<CStatus<int> > alist;

/S
--
Stefan Naewe
stefan_DOT_naewe_AT_atlas_DOT_de
Back to top
Ian Collins
Guest





PostPosted: Thu Aug 17, 2006 9:10 am    Post subject: Re: how to put template class into container Reply with quote



海风 wrote:
Quote:
i have made a template class like this,
template< typename T
class CStatus
{
public:
~CStatus(){}
void OnRender(CDisplay * pDisplay)
{
if ( C24Operator::operator_empty != _status)
{
_t->Render(pDisplay);

}
}
C24Operator::status_operator _status;
T _t;
public:
CStatus(C24Operator::status_operator st, T t)
{
_t =t;
_status = st;
}
private:
CStatus( const CStatus&);
CStatus operator=(const CStatus&);
};

Now i want to put its entities into a container ,for example a list
list<CStatus<>> alist is error, how should i do? thanks ahead

Leave a space.


std::list<CStatus<> > alist;

--
Ian Collins.
Back to top
Rickfjord
Guest





PostPosted: Thu Aug 17, 2006 9:10 am    Post subject: Re: how to put template class into container Reply with quote

Hi,

I have had a similar problem where it was not possible to declare a
std::vector using a std::pair as element type, i.e.

std::vector<std::pair<...>>

I solved this by making a typedef of the pair,

typedef std::pair<...> MyPair;

and then using this in the vector,

std::vector<MyPair>

this solved the problem for me. I hope you get some results from it.

Best regards,
Stefan Rickfjord
M.Sc. Software Engineer


海风 wrote:
Quote:
i have made a template class like this,
template< typename T
class CStatus
{
public:
~CStatus(){}
void OnRender(CDisplay * pDisplay)
{
if ( C24Operator::operator_empty != _status)
{
_t->Render(pDisplay);

}
}
C24Operator::status_operator _status;
T _t;
public:
CStatus(C24Operator::status_operator st, T t)
{
_t =t;
_status = st;
}
private:
CStatus( const CStatus&);
CStatus operator=(const CStatus&);
};

Now i want to put its entities into a container ,for example a list
list<CStatus<>> alist is error, how should i do? thanks ahead
Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.