I am trying to Overload the << operator so it would print out my array recursive
ID: 3568433 • Letter: I
Question
I am trying to Overload the << operator so it would print out my array recursively. Having a lot of trouble.
Can anyone type out an overloading class method that overloads << to print out an array using recursion.
To clarfiy, you only have an array[5] private member in the class. your << operator should print that out recursivly. Given the program there are no accessors or mutators, but I did attempt to add them unless there is a way to do so without.
This is what I attempted.
int recursionAlgo::getarray(){
for(int i=0;i<=4;i++){
cout<<array[i]<<" ";}
}
ostream& operator<<(ostream& os, recursionAlgo& rhs){
return (os<<rhs.getarray());
}