title: Manipulate members of vector in class
body: <p>I am getting started on writing classes and have the following question.
  Suppose I have the following class:</p>
  
  <pre><code>class foo
  {
  private:
      int bar;
  public:
      foo(int bar): bar(bar){}
      void set_bar(int ubar){bar=ubar;}
      int get_bar(){return bar;}
  };
  </code></pre>
  
  <p>Now I want to write a class that contains instances of <code>foo</code>.</p>
  
  <pre><code>class foo_cont
  {
  private:
      vector&lt;foo&gt; foo_vec;
  public:
      foo_cont(){}
      void add_element(foo f1){foo_vec.push_back(f1);}
  };
  </code></pre>
  
  <p>Lets say I make an instace of <code>foo_cont f1;</code> and fill <code>foo_vec</code>it with instances of <code>foo</code>. How do I modify the elements of <code>foo_vec</code> with <code>set_bar()</code>?</p>
  
  <p>Edit:
  Since I am quite new to stack overflow this might be a really stupid question but why am I getting downvotes?</p>