Geting these Error using Inheritance in Visual Studio 2008

I keep getting the following errors

reverse.cpp(10) : error C2653: 'ReserveString' : is not a class or namespace name
reverse.cpp(10) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
reverse.cpp(10) : error C2550: 'ReserveString' : constructor initializer lists are only allowed on constructor definitions


I can't seam to figure out why I am getting these errors in Visual C++ 2008 does VS have a special way to call inheritance hope this helps here is the code


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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
#include <iostream>
#include <string>
#include <ctype.h>
#include <cstddef>
#include "string.h"

using namespace std;


String::String(){


	length = 0;
	buf = new char[length + 1];
    buf[0] = '\0';
    //name[0] ='\0';
}




String::String(char* s){

	length = strlen(s);
	buf = new char[length + 1];
	strcpy(buf,s);
   // name[0] ='\0';
}

String::String(char c){ 

	length = 1;
	buf = new char[2];
	buf[0] = c;
	buf[1] = '\0';
}



String::String(int i){ 

	length = i;
	buf = new char[i+1];
}


String::String(const String& strg){ 

	length = strg.length;
	buf = new char[length+1];
	strcpy(this->buf,strg.buf);
   // name[0] = '\0';
}


String::String(char c,int repeat){ 

	length = repeat;
	buf = new char[repeat+1];
	for(int i = 0;i <= length;i++){ 

		buf[i] = c;

	}

}

String::~String(){

	delete [] buf;
	//delete [] name;
	length=0;

}


String& String::operator=(const String& s){ 

	if(this != &s){ 
        delete [] buf;
		length = s.length;
		buf = new char[s.length+1];
		strcpy(buf,s.buf);
	}


	return *this;
}

String& String::operator=(char* s){ 

	if(strcmp(buf,s) != 0){
		delete [] buf;
		length = strlen(s);
		buf = new char[length+1];
		strcpy(buf,s);
	}

	return *this;
}

String operator+(const String& s1,const String& s2){


	String temp(s1.length+s2.length);
    strcpy(temp.buf,s1.buf);
	strcat(temp.buf,s2.buf);

	return temp;

}


String operator+(const String& s1,char c){ 
	int catlen = (s1.length + 1);
	String temp (catlen);
	strcpy(temp.buf,s1.buf);
	temp.buf[catlen-1] = c;
	temp.buf[catlen]='\0';
	return temp;
}


String operator+(char c,const String& s2){ 
	int catlen =(s2.length + 1);
	String temp(catlen);
	strcpy(temp.buf,s2.buf);
	temp.buf[catlen-1]=c;
	temp.buf[catlen]='\0';
	return temp;
}



String operator+(const String& s1,const char* s2){ 
    int stringlen = strlen(s2);
	String temp(s1.length+stringlen);

	strcpy(temp.buf,s1.buf);
	strcat(temp.buf,s2);

	return temp;
}


String operator+(const char* s1,const String& s2){ 
	int s1len = strlen(s1);
	String temp(s1len + s2.length);
	strcpy(temp.buf,s1);
	strcat(temp.buf,s2.buf);
	return temp;
}

int operator== (const String& s1,const String& s2) { 
	
	if(strcmp(s1.buf,s2.buf) == 0){ 
		return 1;
	}

    return 0;
}


int operator< (const String& s1,const String& s2){ 
	if(strcmp(s1.buf,s2.buf) <= -1 ){
		return 1;
	}

	return 0;
}

int operator<= (const String& s1,const String& s2){
	if(strcmp(s1.buf,s2.buf) >= 1 || strcmp(s1.buf,s2.buf) == 0){ 
		return 1;
	}

	return 0;

}

int operator> (const String& s1,const String& s2){ 
	if(strcmp(s1.buf,s2.buf) >= 1){ 
		return 1;
	}

	return 0;

}


int operator>= (const String& s1,const String& s2){ 

	if(strcmp(s1.buf,s2.buf) > 1 || strcmp(s1.buf,s2.buf) == 0){ 
		return 1;
	}

	return 0;
}

char* operator+(const String& s,int i){ 
	char* temp ;
	temp = new char[2];
	if(i<= s.length && i>=0){
         temp[0] = s.buf[i];
		 temp[1] = '\0';
		return temp;
	}

	cout<<"Error: Out of Bound Error";
	return temp = '\0';
}


char* operator+(int i,const String& s){ 
	char* temp ;
	temp = new char[2];
	if(i<= s.length && i>=0){
         temp[0] = s.buf[i];
		 temp[1] = '\0';
		return temp;
	}

	cout<<"Error: Out of Bound Error";
	return temp = '\0';
}



String String::operator+()const { 
	char* tempstr;
	int count=0;
	String temp(length);

	tempstr = new char[length +1];
	for(int i= 0;buf[i] != '\0';i++){ 
		if(islower(buf[i]))
		{
			tempstr[i] = toupper(buf[i]);
		}else { 
			tempstr[i] = buf[i];
		}

		count++;

	}

    tempstr[count] = '\0';
	strcpy(temp.buf,tempstr);

	return temp;
}



String& String::operator ++(){ 
	for(int i = 0;i <=length;i++){
		++buf[i];
	}
    buf[length]='\0';
	return *this;
}


String String::operator++ (int i){ 
	String temp(length); 
	for(int i=0;i < length;i++){ 
		temp.buf[i] =buf[i];
		++buf[i];
	}
    temp.buf[length] = '\0';
	buf[length]='\0';
	return temp;
}


String& String::operator-- (){ 
	for(int i = 0;i <= length;i++){ 
		--buf[i];
	}
	buf[length]='\0';
	return *this;
}

String String::operator--(int i){
	String temp(length);
	for(int i = 0;i < length;i++){ 
		temp.buf[i] = buf[i];
		--buf[i];
	}
	temp.buf[length] = '\0';
	buf[length]='\0';
	return temp;
}
			
char& String::operator [](int index){
	if(index <= length && index >=0){ 
		
		return buf[index];
	}else {

		cout<<"Error: Out of Bounds Error";
        char* temp = "";
		
		
		
		return *temp ;
	}

}

String& String::operator+=(const String& s){ 
	char* tempstr;
    int templen = length + s.length;
	tempstr = new char[templen + 1];
	strcpy(tempstr,buf);
	strcat(tempstr,s.buf);
    delete [] buf;
	buf = new char[templen + 1];
	strcpy(buf,tempstr);
	length =templen;

	return *this;
}


String String::substr(int start,int stop){
	
	if(start < stop && start>=0 && stop<= this->getLength()){
          char* temp;
		  temp = new char[(stop-start)+1];
		  int j = 0;
		  for(int i= start;i < stop && buf[i] != '\0';i++){
			  temp[j] = buf[i];
			  j++;
		  }
          temp[j] = '\0';
		  return String(temp);
	}


	return String();
}
		
ostream& operator<< (ostream& os,const String& s){ 
	os<<s.buf;
	return os;
}


void String::setName(char* s){ 

	name = new char[strlen(s)+1];
	strcpy(name,s);
}


void String::print(){ 

	cout<<this->buf<<endl;
}


int String::getLength(){ 

	return length;
}




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
#ifndef _STRING_H
#define _STRING_H

#include <iostream>


class String{

protected:
	int length;
	char* buf;
	char* name;
public:
	String();
	String(char* s);
	String(int i);
	String(char c);
	String(const String& s);
	String(char c,int repeat);
	~String();
	String& operator=(const String& s);
	String& operator=(char* s);
	friend String operator+(const String& s1,const String& s2);
	friend String operator+(const String& s1,const char* s2);
	friend String operator+(const char* s1,const String& s2);
	friend String operator+(const String& s1,char c);
	friend String operator+(char c,const String& s2);
	friend char* operator+(const String& s,int i);
	friend char* operator+(int i,const String& s);
	friend int operator==(const String& s1,const String& s2);
	friend int operator< (const String& s1,const String& s2);
	friend int operator<= (const String& s1,const String& s2);
	friend int operator> (const String& s1,const String& s2);
	friend int operator>= (const String& s1,const String& s2);
	friend std::ostream& operator<<(std::ostream&,const String& s);
	String& operator++();
	String operator++(int i);
	String& operator-- ();
	String operator--(int i);
	String substr(int start,int stop);
	char& operator[] (int index);
	String operator+()const ;
	String& operator+=(const String& s);
	void setName(char* s);
	int getLength();
    void print();

};







#endif 





1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#ifndef H_REVERSE
#define H_REVERSE
#include "string.h"

class ReverseString:public String{


private:
	char* stg; 
public:
	ReverseString();
};




#endif 




1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <iostream>
#include <string>
#include "string.h"
#include "reverse.h"


using namespace std;


ReserveString::ReserveString():String(){




}


reverse.cpp(10) : error C2653: 'ReserveString' : is not a class or namespace name
Your function is called ReverseString().

reverse.cpp(10) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
No return type.
Topic archived. No new replies allowed.