```cpp
#include <iostream>
#include <vector>

using namespace std;

// Function to find the maximum value of a knapsack with given weight limit
int knapSack(int W, vector<int> wt, vector<int> val, int n) {
    // Create a 2D table for dynamic programming approach
    vector<vector<int>> K(n + 1, vector<int>(W + 1));

    // Build the table in bottom-up manner
    for (int i = 0; i <= n; i++) {
        for (int w = 0; w <= W; w++) {
            if (i == 0 || w == 0)
                K[i][w] = 0;
            else if (wt[i - 1] <= w)
                K[i][w] = max(val[i - 1] + K[i - 1][w - wt[i - 1]], K[i - 1][w]);
            else
                K[i][w] = K[i - 1][w];
        }
    }

    return K[n][W];
}

int main() {
    int n, W;
    cout << "Enter the number of items: ";
    cin >> n;

    vector<int> val(n), wt(n);

    cout << "Enter the values and weights of the items:" << endl;
    for (int i = 0; i < n; i++) {
        cin >> val[i] >> wt[i];
    }

    cout << "Enter the weight limit of the knapsack: ";
    cin >> W;

    cout << "The maximum value that can be obtained is: " << knapSack(W, wt, val, n) << endl;

    return 0;
}
```

This C++ program implements the 0/1 Knapsack problem using dynamic programming. The user is asked to input the number of items, their values and weights, and the weight limit of the knapsack. The program then calculates the maximum value that can be obtained by including or excluding each item in the knapsack while keeping the total weight under the given limit.

To compile and run the program:

1. Save the code in a file named `knapsack.cpp`.
2. Open a terminal/command prompt and navigate to the directory containing the saved file.
3. Compile the code using the command: `g++ -o knapsack knapsack.cpp`
4. Run the compiled program using the command: `./knapsack` (on Linux/Mac) or `knapsack.exe` (on Windows).
Create a C++ program that implements the Knapsack problem using dynamic programming. Given a set of items, each with a weight and a value, determine the number of each item to include in a collection so that the total weight is less than or equal to a given limit and the total value is as large as possible.
