How to generate rooms in C++?

How can I do something like this:

Video

By using C++ code…
I also want to change the size of the rooms…