necklace
is a c-array consisting of elements that are set<Pearl>
, where Pearl
is a user-defined type.
necklace
is defined as follows
set<Pearl> necklace[NUM_CIRC] = { };
After this the elements are populated with the Pearl
's.
The following snippet
for (Pearl &p : necklace[circular_coordinate]) {
p.set_color("white");
}
results in a compile error
invalid initialization of reference of type 'Pearl&' from expression of type 'const Pearl'
How can I access necklace[circular_coordinate]
is a non-const fashion?
Aucun commentaire:
Enregistrer un commentaire