Re: Type of pointer to function?
From: Josh Sebastian (curien_at_cox.net)
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
>> 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 )
typedef void (MainWindow::*FinishFnct)(QNetworkOperation* op);
> Using that you get
> vid getString( const QString&, const QObject*, FinishFnct )
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.