0

problem is that it prints out backwards, can't figure out a way to flip it. prolbem is with numbers[siz-1] which begins at last index not first.

template<class T>
	T my_vector<T>::show_vector(unsigned int siz)
	{
		if(siz==1)
		{
			cout<<"enter size of array is 1\n";
			return numbers[0];
		}
		else
		{
			cout<<"enter this statement"<<endl;	
			cout<<numbers[siz-1]<<"\n";
			return show_vector(siz-1);
		}
	}

Edited by lotrsimp12345: n/a

2
Contributors
4
Replies
7
Views
8 Years
Discussion Span
Last Post by lotrsimp12345
0

Try it,

template<class T>
T my_vector<T>::show_vector(unsigned int siz){
  if(siz!=0){
      show_vector(siz-1);
    }
  cout<<numbers[siz-1]<<"\n";
  return 0;
}
0

almost working just prints out memory location and i believe that is because of the 0 i think it should be ==1.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.