Variable has been deprecated in python but is still a thing in cpp.
You should use them the same way it is done in the example. Note that you are responsible for creating the proper computational graph in cpp !