How can I access member variables of a vector of objects that is a member variable from a class? : <p>I do know how to access member variables given a vector of objects but suppose </p>

<p>if I have a class called "layer" that is </p>

<pre><code>class layer{
    public: 
        layer(.... that initializes "val" .... ); 
        vector&lt;vector&lt;double&gt;&gt; getval(){return val;}
    private:
        vector&lt;vector&lt;double&gt;&gt; val; 
}
</code></pre>

<p>and then suppose there is another class that is </p>

<pre><code>class Net{
    public:
        Net( ..... that initializes "nn" ..... ); 
        vector&lt;layer&gt; getnn(){ return nn; }
    private:
        vector&lt;layer&gt; nn; 
}
</code></pre>

<p>So in the main function, I could create an object like </p>

<pre><code>Net n( ....... ) 
</code></pre>

<p>and in the main function I could get vector of objects via </p>

<pre><code>n.getnn(); 
</code></pre>

<p>but the question is how could I get the specific, given i index, </p>

<pre><code>vector&lt;vector&lt;double&gt;&gt; val 
</code></pre>

<p>at nn[i]</p>
