I am trying to teach myself C++ coding but am having a problem with classes and objects. I need to pass my objects to a function which may use various object attributes in calculations but may also change the original values of these attributes. My code is:
using namespace std;
int main ()
int n, i = 0;
cout << "How many fish in population? ";
cin >> n;
Fish river[n]; //creating array of objects
for(int i=0;i<n;i++) //outputting info
cout << "Fish " << i << " Weight " << river.weight;
cout << " Age " << river.age << " Eggs " << river.eggs << endl;
system ( "PAUSE" );
So I have a class called fish, which have objects called river (ie these are fish in a river). the river objects have attributes called age, weight and eggs. I need to pass the whole array of objects to a function where I can play with the attribute values or change them if necessary.
I have been playing with pointers and references but can not get them to work with an array of objects like I have.
Pls help a newby!