lundi 29 décembre 2014

c++ why */ in quoted string ends a multiline comment

I have the following piece of code:



/*
string x = "this is a */ test string"
*/


Question


Why */ in the string: "this is a */ test string ends the multi-line comment and thus making the code un-compilable?


Notes



  1. I know how to overcome that but I'm more interested in why was it defined that way?

  2. this issue is generated due to string translation. translating this string abcd with this translation mapping a->1, b->*, c->/, d->2 generates this string 1*/2 which lead to this issue (when the string is defined within multi-line comment).


Aucun commentaire:

Enregistrer un commentaire