Re: Type of pointer to function?

From: Josh Sebastian (curien_at_cox.net)
Date: 01/21/04


Date: Wed, 21 Jan 2004 17:35:24 -0500

On Wed, 21 Jan 2004 16:38:36 +0100, Karl Heinz Buchegger wrote:

> Sam Dutton wrote:
>>
>> I want to pass a function as an argument. (I'm using Qt, compiling with
>> Visual Studio .net).
>>
>> The function to be passed looks like this:
>>
>> void MainWindow::finishedProgrammes(QNetworkOperation *op)
>>
>> How should the declaration look? I've tried the following, but it leads to a
>> 2664 error in Visual Studio .net:
>
> Next time please post the entire text of the error message, 2664 dosn't
> mean anything to anybody unless he/she is using VC .net
>
>
>> void getString(const QString&, const QObject*, void
>> (*)(QNetworkOperation*));
>>
>> How should the function look? I've tried the following:
>
> For things like function pointers it's always the best
> to start with a typedef
>
> typedef void (* MainWindow::FinishFnct)( QNetworkOperation *op )

ITYM

  typedef void (MainWindow::*FinishFnct)(QNetworkOperation* op);

> Using that you get
>
> vid getString( const QString&, const QObject*, FinishFnct )

To OP:
That is a pointer to member function, which is very different from a
pointer to function. If you aren't familiar with them, I suggest you look
them up in your favorite textbook.

Josh



Relevant Pages

  • Build regressions/improvements in v2.6.36-rc3
    ... declaration of function 'iowrite8': => 46 ... of 'memcpy' discards qualifiers from pointer target type: ... pointer types lacks a cast: ... dynamic stack allocation: => 392 ...
    (Linux-Kernel)
  • Build regressions/improvements in v2.6.36-rc2
    ... of 'memcpy' discards qualifiers from pointer target type: ... pointer from integer without a cast: ... fs/eventpoll.c: warning: 'pwq' may be used uninitialized in this ... or declaration, which is probably not what you want: ...
    (Linux-Kernel)
  • Re: including cray pointers in fortran modules
    ...  pointer (ipt, x) ... The first layer is with the declaration of ipt and that PROGRAM ... Cray pointer at has 4 bytes of precision; ...   ...
    (comp.lang.fortran)
  • on topic to clc [Was: Banks and economy]
    ... pointer type - which I think is correct for "arrays", ... Since, as a formal parameter, char cptr[]; ... pointer to the 'completing' declaration, ...   tentative definition. ...
    (comp.lang.c)
  • RE: MIDL2039: interface does not conform to [oleautomation] attribute
    ... > compatible BSTR pointer. ... the IDL declaration produces the following warning: ... > component is that this one is passed as a pointer. ...
    (microsoft.public.win32.programmer.ole)