void show_all(vector<stock> stocks)
{
vector<stock>::iterator AccessStocks;
for(AccessStocks = stocks.begin(); AccessStocks != stocks.end(); AccessStocks++)
{
cout<<endl<<"Ticker: "<<AccessStocks->GetTicker()<<endl;
cout<<"Date: "<<AccessStocks->GetDate()<<endl;
cout<<"Open: "<<AccessStocks->GetOpen()<<endl;
cout<<"High: "<<AccessStocks->GetHigh()<<endl;
cout<<"Low: "<<AccessStocks->GetLow()<<endl;
cout<<"Close: "<<AccessStocks->GetClose()<<endl;
cout<<"Volume: "<<AccessStocks->GetVolume()<<endl;
}
}
To a function that will upon a switch statement will allow for searches by different criteria like ticker, date, etc.
Essentially I have the function for search by ticker:
void find(vector<stock> stocks)
{
vector<stock>::iterator AccessStocks;
string search;
cout<<"Enter the stock you'd like to search for";
cin>>search;
for(AccessStocks = stocks.begin(); AccessStocks != stocks.end(); AccessStocks++)
{
if(AccessStocks->GetTicker() == search)
{
cout<<endl<<"Ticker: "<<AccessStocks->GetTicker()<<endl;
cout<<"Date: "<<AccessStocks->GetDate()<<endl;
cout<<"Open: "<<AccessStocks->GetOpen()<<endl;
cout<<"High: "<<AccessStocks->GetHigh()<<endl;
cout<<"Low: "<<AccessStocks->GetLow()<<endl;
cout<<"Close: "<<AccessStocks->GetClose()<<endl;
cout<<"Volume: "<<AccessStocks->GetVolume()<<endl;
}
}
}
But I know that all of these will have [code]AccessStocks->...[code] so I want to pass the pointer to AccessStocks into a function however I don't really know how to do this.

New Topic/Question
Reply



MultiQuote





|