Maybe my English is even worse I’ve supposed so far, but these requirements sound either contradictory or deceitful.
The assignment asks:
The class must have two public accessors as follows. to_string_24 must return a 5-character string formatted as hh:mm, while to_string_ap must return a string formatted as [h]h:mm xM where x is either A or P |
How do you interpret the statement “5-character string”? Because it sounds like a C-style
char mystring[5]
.
But, if this array is dynamically allocated inside one of the mentioned methods, then it should be deleted inside the destructor, while a previous statement says:
use the default destructor |
, which can’t be aware of that array.
On the other hand, if you introduce a C-style string between the properties, that would justify the request of a non default copy constructor (which otherwise is incomprehensible, as mbozzi pointed out), but it would contradict the following statement:
The class can have no other public methods, and no other fields. |
So, please, could someone help me understanding better? I’m I just making things more complicated than they are or am I really missing something?
jlin55, could you please clarify me if this is an assignment and if you’re allowed to use std::string or not?
If this is an assignment, have you already read here?
http://www.cplusplus.com/forum/beginner/1/
Don't post homework questions
Programmers are good at spotting homework questions; most of us have done them ourselves. Those questions are for you to work out, so that you will learn from the experience. It is OK to ask for hints, but not for entire solutions. |
I’m asking it you because it doesn’t seem you’re following the suggestion you’ve already received, as if you were asking for the solution. Is that what you want? A solution with std::string or C-style strings?