Digit

Nov 14, 2012 at 10:03pm
I need your help.. really.. please..

I want to create a class which allows only digits to be stored and other character uses will throw in Exceptions
All error checking (bounds checking of indices, etc.) must be handled as exceptions (try, throw, catch). And the test program has to show that All exceptions work..

So what i have is this much:
DigitString.h
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
#ifndef DIGIT_STRING_H
#define DIGIT_STRING_H

#include "WCS_String.h"
#include <iostream>
#include <cctype>

using namespace std;

class DigitString: public WCS_String
	{
	public:
					DigitString ();
					DigitString (const DigitString &);
					DigitString (const WCS_String &);
					~DigitString ();
	DigitString & Concat	(const DigitString &);
	DigitString & Concat	(const WCS_String &);
	bool	SetAt	(char, int);
	DigitString & operator =	(const DigitString &);
	DigitString & operator =    (const WCS_String &);
	private:
		char &		operator []	(int);
	};
inline DigitString & DigitString::Concat (const DigitString & D)
	{
	WCS_String::Concat (D);
	return *this;
	}

inline DigitString & DigitString::Concat (const WCS_String & A)
	{
	WCS_String::Concat (A);
	isdigit ();
	return *this;
	}

inline bool DigitString::SetAt (char c, int i)
	{
	return WCS_String::SetAt (isdigit (C), i);
	}

inline DigitString & DigitString::operator = (const DigitString & D)
	{
	WCS_String::operator = (D);
	return *this;
	}

inline DigitString & DigitString::operator = (const WCS_String & A)
	{
	WCS_String::operator = (A);
	isdigit ();
	return *this;
	}


#endif

DigitString.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include "DigitString.h"

DigitString::DigitString ()
	{
	}

DigitString::DigitString (const DigitString & D): WCS_String (D)
	{
	}

DigitString::DigitString (const WCS_String & A): WCS_String (A)
	{
	isdigit ();
	}

DigitString::~DigitString ()
	{
	}


So my question is : is the above code right and what i need to remove or add + what should i put in my Main.cpp for this isdigit to work?
Nov 14, 2012 at 10:15pm
Nov 15, 2012 at 1:17am
No problem, help me
Topic archived. No new replies allowed.