Hello everyone!
I am new to C++, and still haven't got to grips with objects, inheritance etc. etc. Anyway, here's the question -

class mainFrame : public Gtk::Window
{ 
private:
     library *m_library;
     player  *m_player;
}

How can member m_player, when finished playing a track, access m_library to select the next track in the album?

Thank you!

Any method of the mainFrame class has access to both m_library and m_player.

So you can have a method called GetNextTrack() (or w/e):

class mainFrame : public Gtk::Window
{ 
public:
     void GetNextTrack()
     {
          //m_library and m_player can both be accessed in this scope
     }
private:
     library *m_library;
     player  *m_player;
}

I'm sorry, I forgot one thing - functions of m_player run in a different thread! What I need is this -

player::play(char* filename)
{
     /* do work */
    ... 
    /* now select the next track from m_player
        to be played */
}

Um, when you say thread, you mean like a multi-thread program, where each thread gets its own share of processor time? I don't have much experience with multi-threading so I don't know if/how it's relevant.

Ignoring that, you basically want a method of m_player to have access to m_library? A simple way to do that would be to pass m_library as an argument:

player::play(char* filename,library* my_library)
{
     /* do work */
    ... 
    /* now select the next track from m_player
        to be played */
}

Then, just call the function from a method of mainFrame and pass m_library as the second parameter.

Also, std::strings win.

Yes, I mean a multi-threaded program - one thread for GUI, another for sound decoding and another for playback.
Anyway, I have tried this way, and everything worked out fine! Thanks!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.