Hello!
I've written a class called Date:
class Date {
private:
int day, month, year;
public:
Date();
Date(const char *d);
//other methods...
};
I want to write a constructor that'll take as a parameter (as you can see) a c-string. That string will look like: "12022010". The first two characters refer to day, the next two characters refer to month and the last 4 characters refer to year. This means that string "12022010" means the 12th of February 2010. So the constructor will take its parameter in this form and give value to private members day, month and year. Does anyone have an idea how can i implement this thought? What comes to my mind is to split the c-string and then use atoi..but i think it's a bit messy thought (and time-consuming)..i want to find a smarter solution..:-/ Any thought will be appreciated..Thank you in advance for reading my post!