I can't understande this code

This is a part of a big code that I have got, and there is a part that at the moment I dont know what it's doing

1
2
3
4
5
6
7
  stream & operator << (ostream & os,DigBCD a) {
	stream & operator << (ostream & os,DigBCD a) {
	os << char(Dig2Char(a)+'0');
	return os;
}
	return os;
}


I know It is overloading operator << but I dont understand this part..
1
2
3

os << char(Dig2Char(a)+'0');



Dig2char is returning a char...It seems like a casting but I dont understande why it's a casting because It return a char and the casting(if it's what I think) is promotining to a char...and I do not understand how is plus '0'...maybe the addiction with a char is the key...somebody has an idea???

Thanks
closed account (E0p9LyTq)
Is there a Dig2Char() function in the code you have?
yes...I think is this one
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

char Dig2Char(DigBCD a) {
	switch (a) {
			case c:
				return '0';
			case u:
				return '1';
			case d:
				return '2';
			case t:
				return '3';
			case q:
				return '4';
			case z:
				return '5';
			case x:
				return '6';
			case s:
				return '7';
			case o:
				return '8';
			case n:
				return '9';
			case E:
			default:
				return 'E';
		}
}

Topic archived. No new replies allowed.