Hi guys,
Just wondering how i would access a particular variable from an object in an array?? Consider the code:
void Animal::arrayDisplay(){
Animal ani;
Animal* arry[3];
string n,c;
int a;
for(int i = 0; i<3; ++i){
cout <<"Input name:" <<endl ;
cin>> n;
cout <<"Input color:" <<endl ;
cin>> c;
cout <<"Input age:" <<endl ;
cin>> a;
arry[i] = new Animal( n, c, a);
if (a < 10) { ani.receive( *arry[i]);}
}
}
void Animal::receive(const Animal &){//How do i get age from arry[1]??}
e.g Suppose i want to access the age variable from arry[1], in receive()..how do i do that?