[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Re: error : invalid use of member (did you forget the `&' ?)
From:       Thomas =?iso-8859-1?q?L=FCbking?= <thomas.luebking () web ! de>
Date:       2004-11-26 6:45:38
Message-ID: 200411260745.38167.thomas.luebking () web ! de
[Download RAW message or body]

On Friday 26 November 2004 00:24, Thiago Macieira wrote:
> Grégoire Alexandre wrote:
> >Hi guys !
> >
> >I am new at C++ programming and I can't figure out what this means (
> > from gcc ):
> >error: invalid use of member (did you forget the `&' ?)
> >error: base operand of `->' is not a pointer
> >
> >Here is the declaration of the function I am trying to use :
> >        const QString & name(){ return m_szName; };
> >
> >How can I call the function name() ?
>
> name()
;)

I guess he has a problem because of the object he's using?
If you created it by 
"Classname *myClass = new Classname(.);",
you'll need to call
 myClass->name(),
but if you did not create a pointer to the object like saying
"Classname myClass(.);"
you'll have to say 
myClass.name()
you could also say 
&myClass->name();
as '&' passes the reference to the object.
If you're referencing from inside the object (class member function, 
Classname::function()) you can simply call "name()" or "this->name()")

However, imho this is not the correct list for those things, as you're asking 
about cpp basics?!

Thomas
-- 
Think, think different. But essentially: Think!
 
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic