 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
海风 Guest
|
Posted: Thu Aug 17, 2006 9:10 am Post subject: how to put template class into container |
|
|
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
|
Posted: Thu Aug 17, 2006 9:10 am Post subject: Re: how to put template class into container |
|
|
海风 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
|
Posted: Thu Aug 17, 2006 9:10 am Post subject: Re: how to put template class into container |
|
|
海风 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
|
Posted: Thu Aug 17, 2006 9:10 am Post subject: Re: how to put template class into container |
|
|
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 |
|
 |
|
|
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
|
|