开发者

calling const member function

开发者 https://www.devze.com 2023-02-12 09:30 出处:网络
i have called const member function of an object. I created an object on MainWindow, den called get_size() after setting size previously.

i have called const member function of an object.

I created an object on MainWindow, den called get_size() after setting size previously.

calling get_size() method of base class Gtk::Window.

It gives error: ‘Gtk::Window’ is not an accessib开发者_高级运维le base of ‘MainWindow’.

MainWindow is inherited from Gtk::Window class

class MainWindow: Gtk::Window
{

};

What could be the reason for this.


Inhertance is private by default for classes. You need to derive from Gtk::Window publicly:

class MainWindow: public Gtk::Window {


should probably be:

class MainWindow: public Gtk::Window
{

};


If you inherit with private word (and that's how you inherit when you don't specify any word for class) every method from Gtk::Window become private in MainWindow (even if it's declared as public or protected in Gtk::Window).

If you inherit with protected word every public methods from base class become protected methods in inherited class. private methods stay as they are.

public inheritance doesn't change anything. It's default inheritance for class declared with struct keyword.

It seems you forgot to use public in class declaration.

0

精彩评论

暂无评论...
验证码 换一张
取 消