getters and setters in class
<p>I am trying to write a program considering that I have a huge array of objects( conatinng some data such as id, name etc) 
I have a display menu something like :</p>

<p><strong>1)</strong></p>

<pre><code>display_menu()
{
    vector&lt; CD &gt; CDArray;
    //some statements to display
    switch(choice)
    {
        //case1 , case 2, ...
        case x;
            for(int i=0; i &lt; CDArray.size(); i++)
                CDArray[i].printCD(); //printCD() is a method of class CD
        //default
    }
}
</code></pre>

<p>but this would lead to a lot of function call overhead if the vector/array is large making it slow.</p>

<p><strong>2)</strong>  shall I delare the function printCD() as inline or</p>

<p><strong>3)</strong>
  declare another object to call the function and pass the vector/array by reference like :</p>

<pre><code>display_menu()
{
    vector&lt; CD &gt; CDArray; 
    CD obj; 
    //some statements to display
    switch(choice)
    {
        //case1 , case 2, ...
        case x;
            obj.printCD(CDArray); //CDArray is passed by reference
        //default
    }
}
</code></pre>

<p>Is there something wrong with the third approach</p>

<p>what approach would you suggest? </p>
