This is the full code

#include <bits/stdc++.h>

using namespace std;

// Knapsack
class Knapsack {
public:
    Knapsack(int capacity, const vector<int>& weights, const vector<int>& values)
        : capacity_(capacity), weights_(weights), values_(values) {}
        
    const std::vector<int>& getWeights() const {
        return weights_;
    }

    const std::vector<int>& getValues() const {
        return values_;
    }

    int getCapacity() const {
        return capacity_;
    }
private:
    int capacity_;
    vector<int> weights_;
    vector<int> values_;
}

I have tried to get variables but it not working the text editor gave me a warning that variables(weight, values and capacity) can not access

    const std::vector<int>& getWeights() const {
        return weights_;
    }

    const std::vector<int>& getValues() const {
        return values_;
    }

    int getCapacity() const {
        return capacity_;
    }
0

There are 0 best solutions below