Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 3

Qt-interest Archive, April 2007
uninitialized reference member in Qt 4.2.3


Message 1 in thread

Guys,

I am kind of confused by the usage of "uninitialized reference" in
Qt4.2.3example.
To be exact, around line 105 in
Qt-4.2.3/examples/graphicsview/portedcanvas/canvas.h,
it goes like:
........
private:
    QGraphicsScene& canvas;
    FigureEditor *editor;
........

As I know, the uninitialized reference is not allowed in c++, then how come
it works here, which is really confusing to me.

Any ideas?

thanks

S.C.

Message 2 in thread

It is initialized in the classes constructor initializer list from the 
parameter 'c':

Main::Main(QGraphicsScene& c, QWidget* parent, const char* name, 
Qt::WindowFlags f) :
    Q3MainWindow(parent,name,f),
    canvas(c)



S.C. Yu wrote:
> Guys,
>
> I am kind of confused by the usage of "uninitialized reference" in 
> Qt4.2.3 example.
> To be exact, around line 105 in 
> Qt-4.2.3/examples/graphicsview/portedcanvas/canvas.h, it goes like:
> ........
> private:
>     QGraphicsScene& canvas;
>     FigureEditor *editor;
> ........
>
> As I know, the uninitialized reference is not allowed in c++, then how 
> come
> it works here, which is really confusing to me.
>
> Any ideas?
>
> thanks
>
> S.C.
>
>
>

--
 [ signature omitted ] 

Message 3 in thread

I just realized that. Thanks.

S.C.

On 4/10/07, Andrew Ward <andy.ward@xxxxxxxxxx> wrote:
>
> It is initialized in the classes constructor initializer list from the
> parameter 'c':
>
> Main::Main(QGraphicsScene& c, QWidget* parent, const char* name,
> Qt::WindowFlags f) :
>     Q3MainWindow(parent,name,f),
>     canvas(c)
>
>
>
> S.C. Yu wrote:
> > Guys,
> >
> > I am kind of confused by the usage of "uninitialized reference" in
> > Qt4.2.3 example.
> > To be exact, around line 105 in
> > Qt-4.2.3/examples/graphicsview/portedcanvas/canvas.h, it goes like:
> > ........
> > private:
> >     QGraphicsScene& canvas;
> >     FigureEditor *editor;
> > ........
> >
> > As I know, the uninitialized reference is not allowed in c++, then how
> > come
> > it works here, which is really confusing to me.
> >
> > Any ideas?
> >
> > thanks
> >
> > S.C.
> >
> >
> >
>
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
> "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/
>
>