I want to override my extraction operator for MyClass
, which has three int
attributes, the first one has no more than three digits, the second one two and the last one.
The input has to be strictly like this: 123-45-6789
, if one of the parts has less digits than the maximum, the user must enter extra 0
s, like 001-02-3456
.
How should I make this? Should I read each letter as a char
and then create the three int
s? What would be the best way to create an int
given a number of char
s?