Get slider value from another different class

Hello guys!

I am having some problems getting the value of a slider which is defined in the class ofapp from another class…
My code is here:


#include "ofMain.h"
#include "ofxGui.h" 
#include "ofxInputField.h"
#include "Myclass.h"

class ofApp : public ofBaseApp {
             int getpulso(); 
             MyThread thread;

         ofxIntSlider pulso;


   int ofApp::getpulso(){
           return pulso;

//My new class…

#pragma once

#ifndef MyClass_H_
#define MyClass_H_
class ofApp;

class MyThread : public ofThread {
 	ofApp aplicacion;

	int pulso = aplicacion.getpulso;


And errors:

pulso is private member of ofApp class and cannot access from another class.

1 Like

Thanks for your answer, but even so I have the same error messages.
Reading error messages, I think that the problem could be that the class ‘ofApp’ isn’t defined… but I don’t know how to define it…

@Dorald have you seen another error?

usually what I do is use ofGetAppPtr(), in the secondary .cpp code. this returns the pointer to the baseApp and you can cast it as an ofApp ptr.

#include "ofApp.h"

((ofApp *) ofGetAppPtr())-> getpulso();

you can’t include ofApp.h in the h file because you will have cyclical includes, but you can do this in the .cpp file.

ps: this forum thead might help