What does `class HelloWorld : public Gtk::Window` mean?

前端 未结 3 1050
面向向阳花
面向向阳花 2021-01-25 06:33

I\'m following the Gtk \"Hello World\" tutorial found here, and I\'ve come across a line in a class declaration I\'ve never seen before (I\'ve only been learning to program for

相关标签:
3条回答
  • 2021-01-25 07:27

    class HelloWorld : public Gtk::Window

    This means the class HelloWorld is publically derived from class Window defined inside Gtk namespace. Gtk::Window is the fully qualified name of that class.

    0 讨论(0)
  • 2021-01-25 07:28

    It means that HelloWorld is derived from Gtk::Window, so it inherits its behaviour.

    HelloWorld represents a Gtk window, so it is just natural to have it derive from the Gtk's window class. It's constructor will probably add a button to the window (the actual window is created by the parent class constructor, which is invoked automatically when a new instance of HelloWorld is created …) and connect a signal handler (on_button_clicked) to the window.

    You can call all of Gtk::Window's methods through an instance of HelloWorld. In turn, HelloWorld can override virtual methods of Gtk::Window to change its behaviour.

    0 讨论(0)
  • 2021-01-25 07:32

    I just want to point out that you should either be using the 3.0 branch of gtkmm or you should use the stable branch of the tutorial.link text

    The 3.0 branch of gtkmm is still under development, and you should expect a few "surprises" now and then.

    0 讨论(0)
提交回复
热议问题