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: http://www.learncpp.com/cpp-tutorial/17-forward-declarations/

alternatively, you could try adding #pragma once (http://en.wikipedia.org/wiki/Pragma-once) to testApp.h if you include it in myClass.h.

thanks a lot for your information.

tried

  
#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

http://forum.openframeworks.cc/t/is-is-possible-to-separate-long-testapp.cpp-files-into-many/12466/2

as I said, “forward declaration of testApp in myClass.h”
see the first part of this answer http://stackoverflow.com/a/13268263/599884

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

also, see http://stackoverflow.com/a/553869/599884