How do I make my procedural Knapsack problem‍​ brute-forcer into an object-oriented one?
<p>This is my first shot at brute-forcing the NP-complete <a href="http://en.wikipedia.org/wiki/Knapsack_problem" rel="nofollow">knapsack problem</a>.  In this form you have a list of items which must be thrown off a plane each with a weight and cost.  The goal is to throw out some remain_weight while minimizing cost.</p>

<p>Each recursion level(y direction if graphed) is a new remain_weight after items have been selected.  A for loop searches through all the items(x direction if graphed)</p>

<pre class="lang-none prettyprint-override"><code>Test Case 1 - Works
Item / Weight / Cost
0      100     101
1      300     297
</code></pre>

<p>What is the best way to put these two functions in a class. </p>

<pre><code>enum item_type {weight, cost};
int algo(int &amp;cost_low, int &amp;cost_high, int throw_weight, int item_id, int item_matrix[][2])
{
    int quantity,remainder;
    quantity=throw_weight/item_matrix[item_id][weight];
    remainder=throw_weight%item_matrix[item_id][weight];
    if(remainder==0)
    {
        cost_low=(quantity-1)*item_matrix[item_id][cost];
        cost_high=quantity*item_matrix[item_id][cost];
        throw_weight-=(quantity-1)*item_matrix[item_id][weight];
    }
    else
    {
        cost_low=(quantity)*item_matrix[item_id][cost];
        cost_high=(quantity+1)*item_matrix[item_id][cost];
        throw_weight-=(quantity)*item_matrix[item_id][weight];
    }
    return throw_weight;
}
int branch(int remain_weight)
{
    static int depth_level = 0;
    static int cost_present=32000;
    int remain_weight_next;
    int cost_low, cost_high, cost_branch;
    depth_level++;
    cout &lt;&lt; "Entering at depth: " &lt;&lt; depth_level &lt;&lt; " :remain_weight: " &lt;&lt; remain_weight &lt;&lt; endl ;
    int item_id, item_count=2; 
    int item_matrix[][2] = 
    {
        {100, 101},
        {300, 297},
    //  {400, 401},
    //  {800, 800}, 
    //  {1200, 1200}, 
    //  {1999, 1800},
    //  {2000, 2000},
    };
    for(item_id=0; item_id&lt;item_count; ++item_id)
    {
        cout &lt;&lt; "--For loop id is: " &lt;&lt; item_id &lt;&lt; endl; 
        if(item_matrix[item_id][weight]&lt;remain_weight)
        {
            cout &lt;&lt; "----item_weight: " &lt;&lt; item_matrix[item_id][weight] &lt;&lt; " : is less than remain_weight : " &lt;&lt; remain_weight &lt;&lt; endl;
            remain_weight_next=algo(cost_low,cost_high,remain_weight,item_id,item_matrix); 
            cost_branch = branch(remain_weight_next);
            cost_present=cost_low + cost_branch;  
            if(cost_present&gt;cost_high)
                cost_present=cost_high;
            cout &lt;&lt; "--**remain_weight: " &lt;&lt; remain_weight &lt;&lt; endl;
            cout &lt;&lt; "--**cost_low: " &lt;&lt; cost_low &lt;&lt; endl;
            cout &lt;&lt; "--**cost_high: " &lt;&lt; cost_high &lt;&lt; endl;
            cout &lt;&lt; "--**cost_branch: " &lt;&lt; cost_branch &lt;&lt; endl;
        }
        else
        {
            cout &lt;&lt; "----item_weight: " &lt;&lt; item_matrix[item_id][weight] &lt;&lt; " : is greater than remain_weight : " &lt;&lt; remain_weight &lt;&lt; endl;
            if(cost_present&gt;item_matrix[item_id][cost])
                cost_present=item_matrix[item_id][cost];
        }
        cout &lt;&lt; "--**cost_present: " &lt;&lt; cost_present &lt;&lt; endl;
    }
    cout &lt;&lt; "Leaving at Depth: " &lt;&lt; depth_level &lt;&lt; endl;
    depth_level--;
    return cost_present;
}
</code></pre>
