So I have an assignment for school that requires me to create a fixed length string class using templates for use as part of a larger project but I'm having trouble getting started with the fixed length string so I thought I'd come here for help. I don't have much experience with templates which is what is causing me problems. My current problem is in the copy constructor which is giving me errors I don't know how to deal with. So here is my class definitions:
template <int T>
class FixedStr
{
public:
FixedStr ();
FixedStr (const FixedStr<T> &);
FixedStr (const string &);
~FixedStr ();
FixedStr<T> & Copy (const FixedStr<T> &);
FixedStr<T> & Copy (const string &);
private:
string Data;
};
And here is the copy constructor that is giving me problems:
template <int T>
FixedStr<T>::FixedStr (const string & Str)
{
if (Str.length() == <T>)
strcpy (FixedStr<T>.Data, Str);
}
Can anyone give me some advice as to how to handle this? Is there are easy error you see or am I approaching the problem the wrong way? Thanks for any help you can give me.