A
AlanJSmith
I am converting some C++ projects from 6 to vs2005
I turned off precompiled headers and common lanuage runtime
support.
template<int nSize> class DBString
{
public:
// Indicates status of string, eg. length, NULL
long nIndicator;
// array of characters of appropriate length holds actual data
unsigned char strValue[((nSize/4)%4==0)? nSize : (nSize/4)*4];
// copy assignment different size oporator
template<int nInSize> operator =(const DBString<nInSize>& strNewValue)
{
_strncpy_s((char*)strValue,nSize,(char*)strNewValue.strValue,nInSize);
}
// copy assignment (same size)
DBString<nSize> DBString<nSize>:perator =(const DBString<nSize>&
strNewValue)
{
_strncpy_s((char*)strValue,nSize,(char*)strNewValue.strValue,nSize);
nIndicator = strNewValue.nIndicator;
}
};
The syntax of the decaration causes me this error when
trying to compile.
\DBString.cpp(12) : error C4430: missing type specifier - int assumed. Note:
C++ does not support default-int
1> .\DBString.cpp(24) : see reference to class template instantiation
'DBString<nSize>' being compiled
I had added DBString<nSize>
DBString<nSize>:: to the copy assignment same size oporator as this was
giving same error and this
seems to work, if i try the same thing with copy assignment different
sizes i get error C3856: 'DBString<nSize>::=': class is not a class
template and adding any type between template<int nInSize> and
operator = without the DBString<nSize>:: gives me a c++ optimizer had
to close send error report to microsoft error.
obviously i have tried lots of variations on the syntax but i am still
flummoxed, there is the chance that what i am trying to do is not allowed in
VS2005 but i am not sure.
I turned off precompiled headers and common lanuage runtime
support.
template<int nSize> class DBString
{
public:
// Indicates status of string, eg. length, NULL
long nIndicator;
// array of characters of appropriate length holds actual data
unsigned char strValue[((nSize/4)%4==0)? nSize : (nSize/4)*4];
// copy assignment different size oporator
template<int nInSize> operator =(const DBString<nInSize>& strNewValue)
{
_strncpy_s((char*)strValue,nSize,(char*)strNewValue.strValue,nInSize);
}
// copy assignment (same size)
DBString<nSize> DBString<nSize>:perator =(const DBString<nSize>&
strNewValue)
{
_strncpy_s((char*)strValue,nSize,(char*)strNewValue.strValue,nSize);
nIndicator = strNewValue.nIndicator;
}
};
The syntax of the decaration causes me this error when
trying to compile.
\DBString.cpp(12) : error C4430: missing type specifier - int assumed. Note:
C++ does not support default-int
1> .\DBString.cpp(24) : see reference to class template instantiation
'DBString<nSize>' being compiled
I had added DBString<nSize>
DBString<nSize>:: to the copy assignment same size oporator as this was
giving same error and this
seems to work, if i try the same thing with copy assignment different
sizes i get error C3856: 'DBString<nSize>::=': class is not a class
template and adding any type between template<int nInSize> and
operator = without the DBString<nSize>:: gives me a c++ optimizer had
to close send error report to microsoft error.
obviously i have tried lots of variations on the syntax but i am still
flummoxed, there is the chance that what i am trying to do is not allowed in
VS2005 but i am not sure.