Reputation: 603
I'm trying to store classes in a 2d array, but with empty fields, or holes, i.e. fields that simply have no content. Since the class itself is quite big, I decided to fill the vector with pointers to the class, so empty fields could be simply written as NULL. I instantly hit a Wall. If I try to initialize the first value of the vector like this:
myVector[0][0]* = classToBeCopied;
I get the following errors: "Syntax Error" "expected primary-expression before '=' token"
I do have a working copy-constructor and operator= for the class. (I am using Eclipse Luna) Thank you in advance!
Upvotes: 0
Views: 110
Reputation: 9602
myVector[0][0]* = classToBeCopied;
If the result of myVector[0][0]
is a type class_ptr*
. Then you could do the following.
class_ptr* p = myVector[0][0];
*p; // Dereference
Therefore the following should be sufficient
*myVector[0][0]
Upvotes: 2