How to create multiple collection using loop?

Hii all , iam working on monogcxx in qt creator . i need to create multiple collection in a loop.
for example
db["Rotation"].insert_many(documents);
i have data of rotation in collection “Rotation”. But i need to Rotation2 , 3 , 4 etc upto n ,
so how to create like that . i know programming logic but dont know mongocxx syntax
error happening when we put string variable in
db[str].insert_many(documents);
what is the correct syntax???

Hi. Have you tried db.getCollection(str)? You can use variables for collection names this way.