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);
		}
	}

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;
}

but it has to be recursive. nvm i see.

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

for recursion don't you need a base case and then all the other cases?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.