0

In a peer review I stumbled across some lines of Qt and more precisely on QSqlQuery that I never experienced before

QSqlQuery query(my_db);
query.prepare("SELECT * FROM Result "
              "WHERE Tag=:some_tag AND Name=:my_name");

I was astonished by the syntax prepare("PlainOldCChain1" "PlainOldCChain2")

What kind of C++ object is "PlainOldCChain1" "PlainOldCChain2" (I would have thought to some Initializer list but without { , } I am a little bit lost. I found only the prototype bool prepare(const QString & query))

acraig5075
  • 10,588
  • 3
  • 31
  • 50
NGI
  • 852
  • 1
  • 12
  • 31

1 Answers1

1

Adjacent string literals with white space in between are simply concatenated.

query.prepare("SELECT * FROM Result "
              "WHERE Tag=:some_tag AND Name=:my_name");

is exactly the same as

query.prepare("SELECT * FROM Result WHERE Tag=:some_tag AND Name=:my_name");


Also see: How does concatenation of two string literals work?
Community
  • 1
  • 1
acraig5075
  • 10,588
  • 3
  • 31
  • 50
  • OK thanks. My mistake. It is fun how we can forget such simple things [Another SO Post on adjacent strings](http://stackoverflow.com/questions/12120944/how-does-concatenation-of-two-string-literals-work) – NGI Feb 09 '17 at 09:37
  • Agreed, that is a more informative answer, have added for future reference. – acraig5075 Feb 09 '17 at 09:42