Outside of C++, I'd consider this sentence to be incorrect:
Andy-a hard-working student-is absent today. |
I would expect it to be written as (note the additional spaces):
Andy - a hard-working student - is absent today. |
To some extent, if you treat "student-is" as two separate words, that is making a correction or change to what was actually written - a bit like the way google search will often return results for something other than what was actually entered.
An earlier example had similar errors:
Hello(why are we greeting again), |
should be
Hello (why are we greeting again), |
again with an additional space.
So, that's something to think about - should the program be making these kinds of alterations to what was written? If that is not regarded as a problem, then other than some sort of dictionary listing common hyphenated words, such as "hard-working", it could be difficult to devise simple rules to distinguish between a valid and invalid hyphenated word.
And so far we haven't discussed the use of the apostrophe versus the single quote :)