Referencing testApp instance inside myClass ?

Hi there,
I’m instantiating objects from myClass.
The myClass.h is included in my testApp.h, as usual.

I want to call a method of testApp from inside myClass.cpp

What is the usual/best way ?

I tried to pass a pointer to testApp (using this as an argument) while instantiating myClass objects but I had to include testApp.h inside myClass.h which had no sense at all (already included in ofMain + gave problems with myClass itself)

Any help around here?

I think a forward declaration of testApp in myClass.h should solve your problem:

alternatively, you could try adding #pragma once ( to testApp.h if you include it in myClass.h.

thanks a lot for your information.


#pragma once  

but it still doesn’t work.

about forward declaration, I don’t know which stuff to declare before…
indeed, XCode is saying that a Vector of myClass objects contains something undefined. This statement is in testApp.h itself and “something” is the myClass name itself :frowning:

you could use singletons and declare variables and methods globally

as I said, “forward declaration of testApp in myClass.h”
see the first part of this answer

basically, in your myClass.h, before your declare myClass (which contains pointers to testApp), put
class testApp;

also, see