I'm trying to write a templated string class that can be converted to another string class of a different character type. However, I'm having some trouble with the templated member functions. I think my syntax is correct, but Dev-C++/GCC 3.2 keeps giving me strange errors. Here's the relevant code:
template< typename CharType >
class String
{
public:
/** Constructs the string from a string of a different character
* type.
*/
template< typename OtherCharType >
String(const String< OtherCharType > &other);
private:
std::vector< CharType >
};
template< typename CharType >
template< typename OtherCharType >
String< CharType >::String< OtherCharType >(const String< OtherCharType > &other)
{
data_.assign(other.data_.begin(), other.data_.end());
}
Here's the related error messages:
Code/lang/String.hpp:211: `String< OtherCharType >' specified as declarator-id
Code/lang/String.hpp:211: no `int
lang::String< CharType >::String< OtherCharType >(const
lang::String< OtherCharType >&)' member function declared in class `
lang::String< CharType >'
Code/lang/String.hpp:211: template definition of non-template `int
lang::String< CharType >::String< OtherCharType >(const
lang::String< OtherCharType >&)'
[edited by - dcosborn on November 27, 2003 5:42:17 AM]