Error: no match for operator [] : <p>I am writing a C++ code and I am getting the above on the title mentioned error at some lines. I do not know why this is happening.</p>

<p><strong>CODE:</strong></p>

<pre><code>#include &lt;iostream&gt;
#include &lt;ctime&gt;
#include &lt;cstdio&gt;
#include &lt;cstring&gt;
#include &lt;cstdlib&gt;
#include &lt;vector&gt;
#include &lt;map&gt;
#include &lt;algorithm&gt;
#include &lt;list&gt;
//#include &lt;Winbase.h&gt;

using namespace std;

// A struct describing a product.
typedef struct Products
{
    string category;
    string name;
    float price;
} Product;

inline void scenario1(int num_cashiers)
{
    vector&lt;Product&gt; products; // It is a vector(a pseudo-second dimension) of products which will be used for each customer
    vector&lt;vector&lt;Product&gt;&gt; customers; // A vector containing all customers
    vector&lt;vector&lt;vector&lt;Product&gt;&gt;&gt; cashiers; // A vector describing the supermarket cashiers declaring a queue of customers for each cashier
    cashiers.reserve(num_cashiers); // I create as many cashiers as the user wants.
    double start = GetTickCount(); // It will be used for counting 10 secs until next update
    vector&lt;int&gt; total_products(num_cashiers); // A vector keeping the total number of products of each queue
    list&lt;string&gt; categories; // A list containing all the categories of the products
    list&lt;float&gt; categories_prices; // A list containing all category prices
    map&lt;string,float&gt; statistics; // A map that keeps the statistical report of the supermarket. It keeps the name of each category and the total amount having been paid by customers for products of this category
    string want_new_customers;
    int number_new_customers;
    int number_products;
    string new_answer;
    int pos_min_cashier;
    string seeQueue;
    int select_cashier;
    string seeAvgTime;
    string seeStatistics;

    while (true)
    {
        double current_time = GetTickCount() - start; // We are taking each and every second.

        // Update every 10 secs (=10000msecs)
        if (current_time &gt;= 10000) //
        {
         ...



        // Creation of the list with the totally paid amount for each category by the customers
        //for (int &amp;i : categories_prices) categories_prices[i] = 0;
        for (int i = 0; i &lt; customers.size(); i++)
        {
            for (int j = 0; j &lt; products.size(); j++)
            {
                Products products[i][j];
                if (products[i][j].category == categories[i]) // HERE I AM GETTING THE ERROR
                    categories_prices = categories_prices + products[i][j].price; // HERE I AM GETTING AN NO MATCH FOR OPERATOR + ERROR
            }
        }

        // Statistical mapping
        for (int i = 0; i &lt; categories.size(); i++) statistics[categories[i]] = categories_prices[i]; // HERE I AM GETTING THE ERROR

         ...

  }
</code></pre>

<p>One thought crossed my mind was to create a function of the following form:</p>

<pre><code>int* operator[](int index)
{
   return arr[index]; // where arr could be the name of any vector of mine
}
</code></pre>

<p>So, was my thought correct? What should I change in my code?</p>

<p>How can I fix the errors I referred to?</p>

<p>Thank you in advance!</p>
