Problem using a vector in .h file


I am trying to convert a processing project of mine to openFrameworks. I ran into a strange error that I couldn’t debug. So I tried to build my class from the ground up and I run into the same error again when I try to use a vector that I declared inside the .h file.

#ifndef __interactivePlants__ofBranch__
#define __interactivePlants__ofBranch__

#include "ofMain.h"

class ofBranch {

    void update();
    void draw();

    ofBranch(float x, float y);
    vector<ofVec2f> joints;


the corresponding .cpp file:

#include "ofBranch.h"

ofBranch::ofBranch(float x, float y) {
    ofVec2f origin;
    origin.x = x;
    origin.y = y;

void ofBranch::update() {


void ofBranch::draw() {

now, if I remove the vector declaration from the .h file, and move it inside the constructor itself, it runs smoothly. Yet, I want to access this vector in a the update() later on. I have a feeling I am missing something very obvious.

Can you explain the error you get ?

The sketch will start and run, but when I press ESC to quit (or click the red circle in the top-left of the screen) it runs into an error, that’s not in the code of my sketch.

EXC_BAD_ACCESS (code=1, address = 0xe########)

The code you posted is fine in itself, looks like your error is probably elsewhere. Can you post the code of your ofApp? At least the stuff that deals with your ofBranch

ok. so, it appears I solved it by saving every file. I was under the strong impression I had (or that XCode did that for me when building a sketch). I feel stupid now.