To create a variable dynamically at run time, the new keyword is used. This creates a variable without a sense of scope, so no matter where it is used to create a new variable, the variable will continue to exist until the program ends or until it is manually destroyed by the delete keyword (as discussed later). The following code creates an integer variable, and this variable is given global scope insofar as it will not be deleted when the function ends. It will not be deleted from memory until the program instructs it to be deleted. The new keyword returns a pointer to the newly created object.
#include <iostream> int main() { int *Number = new int; *Number = 5; std::cout<<*Number; return 0; }