title: Do while loop in class c++
body: <p>I am having a problem,more of a personal confusion,with a part of my code.You see the point is after asking the question about name amount weight given by n by user it should ask "add more?" and if replied Y or y it should either ask again for how many products do you want or just add 1 more.</p>
  
  <pre><code>class Class
  {
  public:
      char ask;
      vector &lt;string&gt; names;
      vector &lt;int&gt; amounts;
      vector &lt;float&gt; weights;
      string name;
      int amount, n;
      float weight;
      void market()
      {
          cout &lt;&lt; "Give the number of products you want to get at Market : " &lt;&lt; endl;
          cin &gt;&gt; n;
      }
  
  void get()
  {
      for (int i = 0; i &lt; n; i++)
              {
                  do
                  {
                  cout &lt;&lt; "Give product name,amount and weight : " &lt;&lt; endl;
                  cin &gt;&gt; name &gt;&gt; amount &gt;&gt; weight;
                  cout &lt;&lt; endl;
                  names.push_back(name);
                  amounts.push_back(amount);
                  weights.push_back(weight);
                  }
                  cout &lt;&lt; "Add more? (Y/n): "; // add more? Go on if yes...
                  cin &gt;&gt; ask;
  
              }while (ask == 'Y' || ask == 'y');
  
          }
  };
  </code></pre>
  
  <p>It is all in a class that i later put in main,is there any way to make it work that way?</p>