I have a private vector list in a class and I want to have a function that returns the vector. I could either say
vector<int> getvectorlist()
{
return vectorlist;
}
or
vector<int> *getvectorlist( )
{
return &vectorlist;
}
or
vector<int> &getvectorlist( )
{
return vectorlist;
}
or just return the value with in the list
int getdata( int Num )
{
vect iter = vectorlist.begi n()+Num;
return (*vect );
}
where in main there would be a for loop calling that function.
so which option is the best choice.
Oh and im just wanting to know what data there is, not wanting to modify the list at all
vector<int> getvectorlist()
{
return vectorlist;
}
or
vector<int> *getvectorlist( )
{
return &vectorlist;
}
or
vector<int> &getvectorlist( )
{
return vectorlist;
}
or just return the value with in the list
int getdata( int Num )
{
vect iter = vectorlist.begi n()+Num;
return (*vect );
}
where in main there would be a for loop calling that function.
so which option is the best choice.
Oh and im just wanting to know what data there is, not wanting to modify the list at all
Comment