Господа, такая проблема...
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QString>
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
void foo (int (*bar)(int), int);
int foo2(int);
private:
Ui::MainWindow *ui;
};
#endif // MAINWINDOW_H
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
foo(foo2, 4);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::foo(int (*bar)(int), int i)
{
(*bar)(i);
}
int MainWindow::foo2(int i)
{
return i;
}
$ qmake
$ make
/usr/bin/uic mainwindow.ui -o ui_mainwindow.h
g++ -c -m64 -pipe -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector --param=ssp-buffer-size=4 -D_FORTIFY_SOURCE=2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt/mkspecs/linux-g++-64 -I. -I/usr/include/QtCore -I/usr/include/QtGui -I/usr/include -I/usr/include/qwt -I. -I. -o main.o main.cpp
g++ -c -m64 -pipe -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector --param=ssp-buffer-size=4 -D_FORTIFY_SOURCE=2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt/mkspecs/linux-g++-64 -I. -I/usr/include/QtCore -I/usr/include/QtGui -I/usr/include -I/usr/include/qwt -I. -I. -o mainwindow.o mainwindow.cpp
mainwindow.cpp: In constructor «MainWindow::MainWindow(QWidget*)»:
mainwindow.cpp:10:16: ошибка: нет подходящей функции для вызова «MainWindow::foo(<unresolved overloaded function type>, int)»
mainwindow.cpp:10:16: замечание: candidate is:
In file included from mainwindow.cpp:1:0:
mainwindow.h:22:10: замечание: void MainWindow::foo(int (*)(int), int)
mainwindow.h:22:10: замечание: no known conversion for argument 1 from «<unresolved overloaded function type>» to «int (*)(int)»
make: *** [mainwindow.o] Ошибка 1