default constructor problems

I am having issues with ascii symbols in my arrays when they constructed. I can't input anymore data into them because they are fixed length string template classes. Any suggestions on how to establish them correctly to allow input?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
#ifndef FIXED_LENGTH_STRING
#define FIXED_LENGTH_STRING

#include <memory.h>
#include <string.h>
#include "WCS_String.h>

template <int NumChars>
	class FixedLengthString: public WCS_String
		{
		public:
														FixedLengthString		();
														FixedLengthString		(const FixedLengthString <NumChars> &);
														FixedLengthString		(const char []);
													
														~FixedLengthString		();
			FixedLengthString <NumChars> &				Copy					(const FixedLengthString <NumChars> &);
			FixedLengthString <NumChars> &				Copy					(const WCS_String &);
			FixedLengthString <NumChars> &				Copy					(const char []);
			FixedLengthString <NumChars> &				operator =				(const FixedLengthString <NumChars> &);
			FixedLengthString <NumChars> &				operator =				(const char []);
			FixedLengthString <NumChars> &				operator =				(const WCS_String &);
			char *										GetData					();
			istream &									ReadLine				(istream & = cin)				throw (...);
			void										SetChars				(const WCS_String &);
			WCS_String &								GetChars				();
			char 										GetElement				(int) const;
			void										SetElement				(int, char);
			ostream &									Display					(ostream & = cout);
			
		private:
			char										Str						[NumChars + 1];
			size_t										CharCount;
		};

template <int NumChars>
	FixedLengthString <NumChars>::FixedLengthString ()
	{
		CharCount = 0;
	}

template <int NumChars>
	FixedLengthString <NumChars>::FixedLengthString (const FixedLengthString <NumChars> & FLS )
	{
		memcpy		(Str, FLS.Str,(NumChars + 1));
	}

template <int NumChars>
	FixedLengthString <NumChars>::FixedLengthString (const char Chars [] )
	{
		strcpy		(Str, Chars);
	}

template <int NumChars>
	FixedLengthString <NumChars>::~FixedLengthString ()
	{
	}

template <int NumChars>
	FixedLengthString <NumChars> & FixedLengthString <NumChars>::Copy (const FixedLengthString <NumChars> & FLS )
	{
		memcpy		(Str, FLS.Str, (NumChars + 1));
		return		*this;
	}

template <int NumChars>
	FixedLengthString <NumChars> & FixedLengthString <NumChars>::Copy (const char Chars [] )
	{
		strcpy		(Str, Chars);
		return		*this;
	}

template <int NumChars>
FixedLengthString <NumChars> & FixedLengthString <NumChars>::Copy (const WCS_String & DS)
	{
		memcpy		(Str, FLS.Str, (NumChars + 1));
		return		*this;
	}

template <int NumChars>
	ostream & operator << (ostream & out, FixedLengthString <NumChars> & FLS)
	{
		FLS.Display();
		return out;
	}

template <int NumChars>
	FixedLengthString <NumChars> & FixedLengthString <NumChars>::operator = (const FixedLengthString <NumChars> & FLS )
	{
		memcpy		(Str, FLS.Str,(NumChars + 1));
		return		*this;
	}

template <int NumChars>
	FixedLengthString <NumChars> & FixedLengthString <NumChars>::operator = (const char Chars [] )
	{
		strcpy		(Str, Chars);
		return		*this; 
	}

template <int NumChars>
	FixedLengthString <NumChars> & FixedLengthString <NumChars>::operator = (const WCS_String & DS)
	{
		memcpy		(Str, DS.Str, (NumChars + 1));
		return		*this;
	}
template <int NumChars>
char * FixedLengthString <NumChars>::GetData () 
	{
		return Str;
	}
template <int NumChars>
	char FixedLengthString <NumChars>::GetElement (int Index) const
	{
		if ((Index > NumChars) || (Index < 0))
			throw 1;
		else
		return Str [Index];
	}

template <int NumChars>
	void FixedLengthString <NumChars>::SetElement (int Index, char Data)
	{
		if ((Index > NumChars) || (Index < 0))
			throw 1;
		else
		 Str [Index] = Data;
	}

template <int NumChars>
    void FixedLengthString <NumChars>::SetChars (const WCS_String & St)
        {
        char temp;
 
        for (int i = 0; i < NumChars; i++)
            {
            St.GetAt (temp, i);
 
            Str [i] = temp;
            }
        }

template <int NumChars>
	ostream & FixedLengthString <NumChars>::Display (ostream & out) 
	{
		return out << Str << endl;
	}

template <int NumChars>
	istream & FixedLengthString <NumChars>::ReadLine (istream & In)
	{
	char			c;
	char *			pTemp;

	CharCount = 0;
	while (((c = ReadChar (In)) != '\n') && !In.eof ())
		{
		Str [CharCount++] = c;
		}
	Str [CharCount] = '\0';
	return In;
	}

#endif
Topic archived. No new replies allowed.