Gtk--: Why does this (specific code) compile at all?





Hi,

I may have a perfectly obvious question, but the answer eludes me and
my (simplistic) understanding of C++:

In my program, I do the following:
     Gtk_Window     win;
     Gtk_VBox  vbox (TRUE, 5);
     win.add (vbox);          // OK

so far so good ... my original code though said:
     win.add (&vbox);    // note the extra '&'

while compiles fine (without warnings), but in my
experience is wrong (and I suspect this line of causing
a core dump under certain OSs).

Now looking at the Gtk-- header files, add() seems to expect
a reference as the first argument:
     void add (Gtk_Widget &child, ...)

As thus my question is: why does this compile at all? Shouldn't
the compiler flag the passing of the vbox pointer as a type
error?

Thanks
--> Robert




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]