I want to return
vector<ofxDTangibleBase * > _tangibles;
in such a way that changes are not allowed.
I tried a lot of things like:
vector<ofxDTangibleBase * >& getTangibles() const { return &_tangibles; }
but then i get:
Non-const lvalue reference to type ‘vector<ofxDTangibleBase *>’ cannot be bind to a temporary of type ‘const vector<ofxDTangibleBase *> *’
Is it possible?
arturo
October 30, 2013, 11:02pm
2
you almost had it
const vector<ofxDTangibleBase * >& getTangibles() const { return _tangibles; }
I did try that
with that i get:
Binding of reference to type ‘vector<[…]>’ to a value of type ‘const vector<[…]>’ drops qualifiers
arturo
October 31, 2013, 1:40am
4
are you sure you have both consts? i’m trying and it works for me
Well i have this in the class:
vector<ofxDTangibleBase * > _tangibles;
But if i make that constant, then i can’t change the array anymore right?
arturo
October 31, 2013, 12:22pm
6
yeah, no that variable shouldn’t be const only the method and the return type in the method
hmm, it works now. But yesterday also my xcode shortkeys did other things then usual so maybe xcode was drunk.