Passing values between classes using getters/setters
<p>I have 3 classes within a C++/JUCE project: KeyboardGUI, Chord, and Audio.</p>

<p>KeyboardGUI receives an int called rootNote and needs to give this to Chord.</p>

<p>Chord needs to then give this value to Audio.</p>

<p>I am attempting to use getters/setters to achieve this, however I am not sure which way round to use them: i.e.: Do I set chord from keyboard GUI, and set Audio from Chord, OR Do I get from keyboardGUI to chord, and get from chord to audio.</p>

<p>From what I can tell, I need to create 1 instance of Chord in either KeyboardGUI or Audio, and use a pointer to access this instance from the other class, but I cannot figure out how to implement this.</p>

<p>Which way round should I be getting/setting? and where should i use an instance or a pointer?</p>

<p>Function to set from KeyboardGUI to chord</p>

<pre><code>            void KeyboardGUI::handleNoteOn (MidiKeyboardState* source, int midiChannel, int midiNoteNumber, float velocity)
            {
            //IS THIS CORRECT?
            chord.setRootNote(midiNoteNumber);
            }
</code></pre>

<p>Getter/Setter Functions within Chord.CPP           </p>

<pre><code>            void Chord::setRootNote(int newNote)
            {
                rootNote = newNote;
            }

            int Chord::getRootNote()
            {
                return rootNote;
            };
</code></pre>

<p>Here I need to access the rootNote and place it in a new variable</p>

<pre><code> void Audio::playChord()
            {

                //get root note from chord - use pointer??;

            }
</code></pre>

<p>Should I be using a pointer within my Audio class? </p>