Note that there are some explanatory texts on larger screens.

plurals
  1. POGet Singleton of class that WILL be included
    text
    copied!<p>i currently have this classes:</p> <p><code>Activity</code>, <code>ActivityManager</code> (that extends <code>Activity</code>).</p> <p>I have one method in <code>Activity</code>, that gets the singleton object of <code>ActivityManager</code>.</p> <p>After a while, i saw that i got into a "live without life" paradox, as ActivityManager will only be "created" by the compiler, AFTER Activity is. So, how do i do this sort of stuff?</p> <p>I mean, how can i get a class of an object that is extended from the first one?</p> <p>I don't even know how to put this on google, so, help me please! Thanks</p> <p><strong>EDIT</strong></p> <p>Simplified <code>Activity</code></p> <pre><code>class Activity { public: void start(); }; void Activity::start(void){ // Start current Activity on the ActivityManager Stack ActivityManager *am; am = ActivityManager::getInstance(); am-&gt;start(this); } </code></pre> <p>Simplified <code>ActivityManager</code>:</p> <pre><code>class ActivityManager: public Activity { private: // Singleton Object static ActivityManager *singleton; public: // Singleton method to return defauld object instance static ActivityManager* getInstance(void); // Overload method, used to run others Activityes void start(Activity&amp; activity); }; // Singleton method to return default ActivityManager object instance ActivityManager* ActivityManager::getInstance(){ if(!singleton) singleton = new ActivityManager(); return singleton; } // Function called on request to start new activity void ActivityManager::start(Activity&amp; activity){ } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload