[Qt-interest] = 0 ?

Jeroen De Wachter jeroen.dewachter at barco.com
Tue Feb 23 13:40:45 CET 2010


Idd, this provides an equivalent to abstract classes/methods in Java

On Tue, 2010-02-23 at 12:34 +0000, Stephen Collyer wrote:
> On 23 February 2010 12:26, Lucas Pereira Caixeta <lpcnew at gmail.com>
> wrote:
>         
>         Hi all,
>         
>         In my interface i have this method: virtual String getName ()
>         = 0;    
>         
>         why this method have  "=0" in the end?
>         so that it serves?
>         
> This has nothing to do with Qt. It's a C++ feature. When you declare
> a method with = 0, you are creating a class that can't be
> instantiated.
> This is called a pure virtual method.
> 
> You can only use this class as as a base of another class, and you
> must
> provide a definition of the pure virtual method to be able to
> instantiate the
> class. 
> 
> The reason this is useful is that it allows a designer to create a
> class which
> specifies the interface of a class, but which doesn't provide all the
> functionaltity itself.
>  
> -- 
> Stephen Collyer
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest



DISCLAIMER:
Unless indicated otherwise, the information contained in this message is privileged and confidential, and is intended only for the use of the addressee(s) named above and others who have been specifically authorized to receive it. If you are not the intended recipient, you are hereby notified that any dissemination, distribution or copying of this message and/or attachments is strictly prohibited. The company accepts no liability for any damage caused by any virus transmitted by this email. Furthermore, the company does not warrant a proper and complete transmission of this information, nor does it accept liability for any delays. If you have received this message in error, please contact the sender and delete the message. Thank you.




More information about the Qt-interest-old mailing list