Saving dataloaders in C++

I want to have a C++ source file that only has a test function (testFunction.cpp). As such, I was wondering if it is possible to read data, create a dataloader and store the dataloader in a .pt file, then load that dataloader in testFunction.cpp .
Thank you,