pointers' array

Hi guys, i made the following code for the class product. In main body i tried to create an array of pointer for the member name but the compiler shows me error.. Any ideas?
Last edited on
closed account (3TXyhbRD)
; after class definition. I do hope your main function doesn't really start with main:
Last edited on
there is a misunderstanding, that i upload is only a sension from my program my question is focus on between the lines 8 to 13 cause i dont know how to create a table of pointers and that i made is from internet sources.
closed account (3TXyhbRD)
Line 9 is the problem. There is no variable name and no size specified for the new array. The types don't match either and the fields in the given class are private.

Try:
 
string* X = new string[50];

For array.
Last edited on
thnx very much
hi again, i have a new question now: how can I print from pointers' array the values from the corresponding member of the class?

1
2
3
4
5
class product {
         private:
        string code;
        string name;
        string information;


i have an array of pointers for the member name and i want to print code values
closed account (3TXyhbRD)
I'll assume your members are public and that you have a default/no parameter constructor.

This should get you going the right direction:
1
2
3
*product[100];
product[0] = new product;
product[0]->code = "myCode";


PS: it is best not to edit a post after it was replied to. Others with the same issue will find the solution without having to ask the same question again.
Topic archived. No new replies allowed.