c++入门题目

来源:百度知道 编辑:UC知道 时间:2024/09/23 20:37:23
下面的定义正确么? 为什么? 如果错,错在哪里?
(1)
const std::string hello = "Hello";
coust std::string message = hello + ",world" + "!";
(2)
const std::string exclam = "!";
coust std::string message = "hello" + ",world" + exclam;
对的 可以加分
更正下题目
(1)
const std::string hello = "Hello";
const std::string message = hello + ",world" + "!";
(2)
const std::string exclam = "!";
const std::string message = "hello" + ",world" + exclam;
这是分开的2题 谢谢

const std::string message = "hello" + ",world" + exclam;
这个有错,+是运用在string对象的
const std::string exclam = "!";
const std::string s1= "hello";
const std::string s2=",world" ;
const std::string message=s1+s2+exclam;

他的意思是:
你第二行和第二题第二行的const拼错了