Inheritance issues

I am trying to figure out why this can't work



void package::users(){ info *uses=new info[3]; }


void package::packagelookup() { uses[0]; }



For whatever reason packagelookup() can't access the uses array. Is there anything I am doing wrong? Thanks



Yes, you're declaring uses inside the scope of users(), so it goes out of scope with the end brace }

If you want to access it across member functions, you need to make it a member variable (most likely private). You should also delete[] it when you are done with it since you're using new[]
Last edited on
Topic archived. No new replies allowed.