pointers array

hi, i have a question: how can I print from pointers' array the values from the corresponding member of the class?



i have an array X[i] of pointers for the member name and i want to print code values
Last edited on
I guess it would be:

cout << X[i]->code;

or I misunderstood your question
You must to provide a public method to access member name.
i made the follow public function according your advices and now i have an error message says for "->"

Last edited on
The type of X is string which of course doesn't have code as member. Change the type of X to product and yes, if you want to access certain members like code you need to make them public.


1
2
3
4
5
6
product* X = new product[50];
         for(i=0;i<N;i++)
         {
          if(name==search)
          X[i]->name=name;
          cout << X[i]-> code=Code << endl;
Last edited on
you were right thnx so much (Y)
Topic archived. No new replies allowed.