您的位置:首页 > 其它

1.3. 关于注释

2015-06-18 16:06 176 查看
Exercise 1.8:  Indicate which, if any, of the following output statements, are legal.

指出下列输出语句哪些(如果有)是合法的。

   std::cout << "/*";

   std::cout << "*/";

   std::cout << /* "*/" */;

After you've predicted what will happen, test your answer by compiling a program with these three statements. Correct any errors you encounter.

预测结果,然后编译包含上述三条语句的程序,检查你的答案。纠正所遇到的错误。

 

 

答:第一二句正确,由于/* 和 */在字符串中,无注释作用。第三句有错,/*会找第一个匹配的*/形成注释,故而错误。
std::cout << /* "*/" */";
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: