template

M

mosfet

I try this but I have an error :

//Declaration
template <class T, class TP>
int _VectorToSC(CArray<T, TP> ItemVec, UCHAR HFileID, UCHAR LFileID);


// implementation
template <class T, class TP>
int CSekureStorage::_VectorToSC(CArray<T, TP> ItemVec, UCHAR HFileID, UCHAR
LFileID)
{
........
}
----------------------------------------------------------------------------
---------------------------


CArray<TNameItem,TNameItem&> m_NameItemVec;

_VectorToSC(m_NameItemVec, 0x3F, 0x02) ;

'int __cdecl CSekureStorage::_VectorToSC(class CArray<struct
TNameItem,struct TNameItem &>,unsigned char,unsigned char)' : cannot convert
parameter 1 from 'class CArray<struct TNameItem,struct TNameItem &>' to
'class CArray<struct TNameItem,struct TNameItem &>'
No copy constructor available for class 'CArray<struct TNameItem,struct
TNameItem &>'


Don't understand???
 
T

tom_usenet

I try this but I have an error :

//Declaration
template <class T, class TP>
int _VectorToSC(CArray<T, TP> ItemVec, UCHAR HFileID, UCHAR LFileID);

What's CArray? UCHAR I assume is a typedef for unsigned char. Are you
sure you meant to pass the CArray (whatever it is) by value? How
about:
//Declaration
template <class T, class TP>
CArray<TNameItem,TNameItem&> m_NameItemVec;

What is TNameItem? Your own class?
_VectorToSC(m_NameItemVec, 0x3F, 0x02) ;

'int __cdecl CSekureStorage::_VectorToSC(class CArray<struct
TNameItem,struct TNameItem &>,unsigned char,unsigned char)' : cannot convert
parameter 1 from 'class CArray<struct TNameItem,struct TNameItem &>' to
'class CArray<struct TNameItem,struct TNameItem &>'
No copy constructor available for class 'CArray<struct TNameItem,struct
TNameItem &>'

CArray<struct TNameItem,struct TNameItem&> isn't copyable, perhaps
because TNameItem isn't copyable. But you attempt to pass it to a
method that takes its argument by value, and hence makes a copy of it
using the copy constructor.

Tom

C++ FAQ: http://www.parashift.com/c++-faq-lite/
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
 
V

Victor Bazarov

mosfet said:
I try this but I have an error :

//Declaration
template <class T, class TP>
int _VectorToSC(CArray<T, TP> ItemVec, UCHAR HFileID, UCHAR
LFileID);

You probably want to make your first argument a _reference_:

.... (CArray said:
// implementation
template <class T, class TP>
int CSekureStorage::_VectorToSC(CArray<T, TP> ItemVec, UCHAR HFileID, UCHAR
--
---------------------------


CArray<TNameItem,TNameItem&> m_NameItemVec;

_VectorToSC(m_NameItemVec, 0x3F, 0x02) ;

'int __cdecl CSekureStorage::_VectorToSC(class CArray<struct
TNameItem,struct TNameItem &>,unsigned char,unsigned char)' : cannot convert
parameter 1 from 'class CArray<struct TNameItem,struct TNameItem &>' to
'class CArray<struct TNameItem,struct TNameItem &>'
No copy constructor available for class 'CArray<struct TNameItem,struct
TNameItem &>'


Don't understand???

No, we do understand.

Victor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,159
Messages
2,570,879
Members
47,416
Latest member
LionelQ387

Latest Threads

Top