Hello all.
I need help with the implementation of an arrayclass operator overloading.
I have created a class 'arrayclass' but need to overload the operator>> so that I can use:
cin >> myArray[0]; // get input from user and store into index 0 of custom arrayclass.
I also have to have it allow:
cin >> myArray; // allow user to input every index in the class (say...0 to 5)
I can get the "cin >> myArray" to work fine. Where I'm having trouble is implementing the one that allows a specific index of the array to be input. Any clues would be helpful....I'm assuming it'll still use the same instream& return value, but could very well be wrong.
....
Same thing with overloading<< (for cout).
I can implement the "entire array" being output...but not a specific index (although it appears to work w/o overloading it...I'm sure there are cases where it will NEED to be overloaded.
anybody?
I need help with the implementation of an arrayclass operator overloading.
I have created a class 'arrayclass' but need to overload the operator>> so that I can use:
cin >> myArray[0]; // get input from user and store into index 0 of custom arrayclass.
I also have to have it allow:
cin >> myArray; // allow user to input every index in the class (say...0 to 5)
I can get the "cin >> myArray" to work fine. Where I'm having trouble is implementing the one that allows a specific index of the array to be input. Any clues would be helpful....I'm assuming it'll still use the same instream& return value, but could very well be wrong.
....
Same thing with overloading<< (for cout).
I can implement the "entire array" being output...but not a specific index (although it appears to work w/o overloading it...I'm sure there are cases where it will NEED to be overloaded.
anybody?