Pointer question

I’m starting to get an idea from actual Cpp programmers what this is, but I figured I’d ask actual JUCE users. this piece of code perplexes me
(from one of the tutorials)

void sliderValueChanged (Slider* slider) override

    if(slider == &frequencySlider && currentSampleRate > 0.0)
    if(slider == &levelSlider && currentSampleRate > 0.0)

Its that first line that has (Slider* slider)

I haven’t seen pointer syntax like that. Could anyone explain what is going on in that one piece of code? It’s driving me nuts!!
Thanks in advance for any help. Just looking to get a deeper understanding of this stuff.

If just the (Slider* slider thing) is something you haven’t seen before, you might beed to brush up your C++ skills quite a bit before continuing with Juce…There’s nothing unusual or advanced about that, it’s just a raw pointer passed into a function as an argument. I wonder what other kind of “pointer syntax” you have seen if that seems unusual to you?

FYC a link, second hit google for pointer and operator:

By the way, it could also be written in the following ways :
(Slider *slider)
(Slider * slider)

They are all the same thing.

And if you are wondering about the “override” keyword, that has nothing to do with pointers, it’s just there to tell the compiler the function is supposed to override a virtual function and give a compiler error if the signature of the function doesn’t exactly match the base class function signature. You could omit using that, but it’s good practice to have that to avoid problems.

1 Like