This example creates a temporary QueryDef on the Employees table and a permanent QueryDef on the Categories table, and then prints a report for each of them.
See How to Build the DAO Method Samples.
If you have installed the DAO SDK, see InstallDirectory\DAOSDK\SAMPLES\CreateQueryDef.cpp.