Quantcast
Channel: beginners - openFrameworks
Viewing all articles
Browse latest Browse all 4929

How to access a variable from ofApp.cpp in another class?

$
0
0

@batchku wrote:

I'm having a difficult time finding a working solution for accessing a variable defined in ofApp.cpp and ofApp.h in another class. The variety of solutions i've research and tried produce a variety of compiler or linker errors.

Here are the techniques i've tried:
- using the extern keyword to define the define the variable in ofApp.h, assign a value to it in ofApp.cpp and the try to use it in myClass.cpp (which has #include ofApp.h) but the name is not recognized. (like this)
- creating a get method in ofApp.cpp, and trying to call that method from 'myClass.cpp. Only works if the get method isstatic, but then thestatic` method can not access variables defined in the offApp class

I'm able to use a header file with lots of constants, defined with #define but I need a way to access variables that change values across multiple files.

Any hints/pointers would be much appreciated!

I'm working with OF 0.98 and XCode 8.2.1.

Posts: 9

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 4929

Latest Images

Trending Articles



Latest Images