using namespace Aspose::Words;

std::vector<String> fileNames { u"Input1.docx", u"Input2.docx" };

auto output = MakeObject<Document>();

output->RemoveAllChildren();

for (const auto& fileName : fileNames){
    auto input = MakeObject<Document>(fileName);
    output->AppendDocument(input, ImportFormatMode::KeepSourceFormatting);
}

output->Save(u"Output.pdf");