Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You seem to have a basic OOP problem at hand. Here's some questions that may lead you in the right direction.</p> <p><strong>How many instances of each class do you need for your program?</strong></p> <p>This depends on what problem you are trying to solve, so only you can give the proper answer.</p> <ol> <li><p>If you need exactly one instance of both classes, then make them <a href="http://en.wikipedia.org/wiki/Singleton_pattern" rel="nofollow">singleton</a> and both will have access to each other, by simply retrieving the singleton instance.</p></li> <li><p>If you need, say, one display instance and multiple job instances, you will want to store the <code>Job</code> instances in a container to which the one <code>Display</code> instance has access. You will want to make the <code>Display</code> a <a href="http://en.wikipedia.org/wiki/Singleton_pattern" rel="nofollow">singleton</a> so that it can be accessed at will.</p></li> <li><p>If you need several instances of both, then you will need to explicitly <em>associate</em> those which need to work together, by passing an already created object to the constructor of the other.</p></li> </ol> <p>Think of this:</p> <pre><code>Display d1, d2; Job j1(&amp;d1), j2(&amp;d2); // make sure not to copy the displays! </code></pre> <p>and in the <code>Job</code> constructor:</p> <pre><code>Job(Display *display): display(display) { display-&gt;setJob(this); } </code></pre> <p>If there need to be multiple displays per job, you will have to replace the single <code>display</code> pointer in Job with a collection of <code>Display</code> pointers and manually add the appropriate displays to that collection.</p> <hr> <p>If this doesn't help, you will need to explain to us what problem you are solving, and we may help further.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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