return vector with pointers as static

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?

you almost had it :slight_smile:

  
  
const     vector<ofxDTangibleBase * >& getTangibles() const { return _tangibles; }    
  

I did try that :slight_smile:
with that i get:

Binding of reference to type ‘vector<[…]>’ to a value of type ‘const vector<[…]>’ drops qualifiers

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?

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.