Passing a class by reference
in
Programming Questions
•
1 year ago
First off, a big hello to everyone! (as this is my first post)
The small snippet below is from his code (I apologize in advance is this is a violation of some sort).
void send_pending_note_offs()
{
Note note;
for(int index = this.open_notes.size() - 1; index >= 0; index--)
{
note = (Note)
this.open_notes.get(index);
if (note.duration <= 1)
---------------------------------------------------------------------------------------------------------
class Note
{
int pitch, velocity, duration;
Note(int pitch, int velocity, int duration)
{
this.pitch = pitch;
this.velocity = velocity;
this.duration = duration;
}
}
In the above code I do not understand what is happening in the highlighted section. My guess is that "note = (Note)" is equivalent to "note = new Note()". If this is the case then I guess it's a matter of personal style/preference coding and I get what's happening. But that would also lead to me to ask, when is one syntax preferable over the other? Or, is there a difference in the impact of each on the program?
Thanks in advance for any knowledge you can share.
Derrick
1