[Gtk-sharp-list] Gtk# constructors
Charles Iliya Krempeaux
charles@reptile.ca
18 Feb 2003 13:08:05 -0800
Hello,
On Tue, 2003-02-18 at 06:57, Lee Mallabone wrote:
[...]
> 3: protected HBox() : base(){}
[...]
> Number 3 looks really odd - I followed the class hierarchy up to
> GLib.Object, and its constructor just does:
>
> public Object () {
> needs_ref = false;
> }
>
> which means, (as far as I can tell), that the internal Gtk C object
> Handle is never instantiated, so you end up with an object that will
> probably crash if you call instance methods on it.
Notice that this constructor has a "protected" access level. That
means that others can't call it.
I'd guess that this is declared so that C# doesn't automagically create
a default constructor for us. In other words, if we did not create
a constructor with the signature:
HBox()
ourselves. Then C# would create one for us. And the one it
created would be "public". And others would be able to call it.
(Which we don't want. So we created one ourselves that was
"protected".)
(Although, if we don't want other to call it, I'd probably make
it "private" instead of "protected". But then again, if you didn't
do that then subclasses of it couldn't call it. I don't know if
that is important or not though. Mike, is it???)
See ya
--
Charles Iliya Krempeaux, BSc
charles@reptile.ca
________________________________________________________________________
Reptile Consulting & Services 604-REPTILE http://www.reptile.ca/