重複の可能性:
2つの文字列リテラルの連結
ケース1 "hello" "world"(エラーなし)
ケース2 "hello"+"world"(エラー)
+演算子は、オペランドの1つをではstring typeなく、として持つ必要があることを私は知っていstring literalます。
どちらの場合も意味がありません。これをsingle literal!に含めることができるからです。
なぜケース1が許可されるのですか?
重複の可能性:
2つの文字列リテラルの連結
ケース1 "hello" "world"(エラーなし)
ケース2 "hello"+"world"(エラー)
+演算子は、オペランドの1つをではstring typeなく、として持つ必要があることを私は知っていstring literalます。
どちらの場合も意味がありません。これをsingle literal!に含めることができるからです。
なぜケース1が許可されるのですか?
C ++は基本的に隣接するリテラルを同じリテラルと見なすため、ケース1が許可されます。つまり、コードは解析の早い段階で"hello" "world"変換されます。"helloworld"
Case 1, as you call it, is a convenient way to let string constants span several lines or be broken up into easily identified parts.
It's there to make your life easier.
Assuming that + should have the same semantics when used with string constants is a mistake. Especially in C, where string isn't an available type.