What is wrong with my code?

I am trying to put in the images for playbutton and stop button but they are not appearing.

Can someone tell me what might have went wrong here?

DeckGUI::DeckGUI(DJAudioPlayer* _player,
juce::AudioFormatManager& formatManagerToUse,
juce::AudioThumbnailCache& cacheToUse)
: player(_player), waveformDisplay(formatManagerToUse, cacheToUse)
{

auto playImage = ImageCache::getFromMemory(BinaryData::playB, BinaryData::playBSize);

auto stopImage = ImageCache::getFromMemory(BinaryData::pauseB_png, BinaryData::pauseB_pngSize);

auto CatImage = ImageCache::getFromMemory(BinaryData::cat_png, BinaryData::cat_pngSize);

addAndMakeVisible(playButton);
addAndMakeVisible(stopButton);


playButton.addListener(this);
stopButton.addListener(this);


stopButton.setImages(true, true, true, stopImage, 0.5f, juce::Colours::lightsalmon, stopImage, 0.5f, juce::Colours::lightsalmon, stopImage, 1.5f, juce::Colours::lightsalmon, 0.0f);
playButton.setImages(true, true, true, playImage, 0.5f, juce::Colours::lightsalmon, playImage, 0.5f, juce::Colours::lightsalmon, playImage, 1.5f, juce::Colours::lightsalmon, 0.0f);
trackName.setReadOnly(true);
trackName.setTextToShowWhenEmpty("No track loaded. Click Load Files to load one!", juce::Colours::lightseagreen);


//Timer loops every 100ms, checks whether user has the "loop" button turned on or off and also updates the current position in the waveform display
startTimer(100);

}

void DeckGUI::resized()
{

double rowH = getHeight() / 7;

playButton.setBounds(0, 0, getWidth() / 5, rowH);
stopButton.setBounds(getWidth() / 7, 0, getWidth() / 7, rowH);
trackName.setBounds((getWidth() / 7) * 2, 0, (getWidth() / 7) * 3, rowH);
loopButton.setBounds((getWidth() / 7) * 5, 0, getWidth() / 7, rowH);
loadButton.setBounds((getWidth() / 7) * 6, 0, getWidth() / 7, rowH);


volSlider.setBounds(0, rowH, getWidth() / 2, rowH * 3);
speedSlider.setBounds(getWidth() / 2, rowH, getWidth() / 2, rowH * 3);

volSliderLabel.setCentreRelative(0.43f, 0.4f);
speedSliderLabel.setCentreRelative(0.94f, 0.4f);


trackName.setColour(juce::TextEditor::backgroundColourId, juce::Colours::transparentBlack);
trackName.setColour(juce::TextEditor::outlineColourId, juce::Colours::transparentBlack);

waveformDisplay.setBounds(0, rowH * 4, getWidth(), rowH * 3);
posSlider.setBounds(0, rowH * 4, getWidth(), rowH * 3);

}

private:
juce::ImageButton playButton{ “PLAY” };
juce::ImageButton stopButton{ “STOP” };
juce::ToggleButton loopButton{ “LOOP” };
juce::TextEditor trackName;
juce::String mtrackName;
juce::TextButton loadButton{ “LOAD” };
juce::Label volSliderLabel;
juce::Label speedSliderLabel;
juce::Slider volSlider;
juce::Slider speedSlider;
juce::Slider posSlider;
DJAudioPlayer* player;
WaveformDisplay waveformDisplay;

JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(DeckGUI)

};

You’re passing a reference to an Image object which goes out of scope

Rail

Where should I be putting the image object?

Rail

as a member variable just like the buttons and stuff. always keep the lifetime of an object in mind in object-orientated programming languages

As others are pointing out…in c++ your first questions when manifesting an object should be around its lifetime. When is the object created and when will it be destroyed? Understanding RAII is an important concept in modern c++ and will help you automate this.