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 :
1)
display_menu()
{
    vector< CD > CDArray;
    //some statements to display
    switch(choice)
    {
        //case1 , case 2, ...
        case x;
            for(int i=0; i < CDArray.size(); i++)
                CDArray[i].printCD(); //printCD() is a method of class CD
        //default
    }
}
but this would lead to a lot of function call overhead if the vector/array is large making it slow.
2) shall I delare the function printCD() as inline or
3) declare another object to call the function and pass the vector/array by reference like :
display_menu()
{
    vector< CD > CDArray; 
    CD obj; 
    //some statements to display
    switch(choice)
    {
        //case1 , case 2, ...
        case x;
            obj.printCD(CDArray); //CDArray is passed by reference
        //default
    }
}
Is there something wrong with the third approach
what approach would you suggest?
 
     
     
     
     
    