Problem in saving variable of ofParameter on vector

Hi. I have a problem in saving variable of ofParameter on vector.
Data of boxes(class box’s vector) from location (gui slider) is always same.

My code is below:


void ofApp::setup(){
    gui.add(location.set("displaysize",ofVec3f(0.4f, 0.2f, 0.02f),ofVec3f(0,0,0),ofVec3f(5, 5, 5))); // value, min, max

void ofApp::draw(){
    ofBackgroundGradient(ofColor::white, ofColor::gray);
       for (int i=0; i<10; i++) {
           box a;
           a.boxlocation.x = location->x;


class box {
    ofVec3f boxlocation;
    ofVec3f boxposition;

class ofApp : public ofBaseApp{
    void setup();
    void update();
    void draw();
    void exit();
    void keyPressed(int key);
    void keyReleased(int key);
    void mouseMoved(int x, int y );
    void mouseDragged(int x, int y, int button);
    void mousePressed(int x, int y, int button);
    void mouseReleased(int x, int y, int button);
    void mouseEntered(int x, int y);
    void mouseExited(int x, int y);
    void windowResized(int w, int h);
    void dragEvent(ofDragInfo dragInfo);
    void gotMessage(ofMessage msg);
    void circleResolutionChanged(int & circleResolution);
    void ringButtonPressed();
    bool bHide;
    ofParameter<float> radius;
    ofParameter<ofColor> color;
    ofParameter<ofVec2f> center;
    ofParameter<int> circleResolution;
    ofParameter<bool> filled;
    ofxButton twoCircles;
    ofxButton ringButton;
    ofParameter<string> screenSize;
    ofxPanel gui;
    ofSoundPlayer ring;
    ofParameter<ofVec3f> location;
    ofParameter<ofVec3f> position;
    vector<box> boxes;

I see some problems with your code.
You are pushing elements to the vector but never clearing it. this means the vector is increasing one item per iteration in the for loop but you are printing only the first 10 elements each frame… is that what you want?

Aside from what Jordi mentioned (which is correct) I don’t think your ofParameter is not a pointer so you will get a compile error on this line:

a.boxlocation.x = location->x;

it should be

a.boxlocation.x = location.x;

location->x is correct. ofParameter implements the -> oeprator to allow access to the variables and functions of the wrapped object