添加一些基本类
This commit is contained in:
58
main.cpp
Normal file
58
main.cpp
Normal file
@@ -0,0 +1,58 @@
|
||||
#include "mainwindow.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QString>
|
||||
#include <QDebug>
|
||||
#include <QTextCodec>
|
||||
#include "base/base.h"
|
||||
#include "base/mycfg.h"
|
||||
|
||||
#define log(fmt, ...) \
|
||||
{ \
|
||||
QString str = QString::asprintf(fmt, ##__VA_ARGS__); \
|
||||
printf("%s", str.toLocal8Bit().data()); \
|
||||
}
|
||||
|
||||
using namespace std;
|
||||
using namespace std::placeholders;
|
||||
|
||||
typedef std::function<void(int, int)> Fun;
|
||||
|
||||
class B
|
||||
{
|
||||
public:
|
||||
void call(int a, Fun f)
|
||||
{
|
||||
f(a, 2);
|
||||
}
|
||||
};
|
||||
|
||||
class Test
|
||||
{
|
||||
public:
|
||||
void callback(int a, int b)
|
||||
{
|
||||
// qDebug()<<a<<"+"<<b<<"="<<a+b<<endl;
|
||||
qDebug("%d+%d=%d,%s", a, b, a + b, QString("ssssss").toLocal8Bit().data());
|
||||
}
|
||||
|
||||
void bind()
|
||||
{
|
||||
Fun fun = std::bind(&Test::callback, this, _1, _2);
|
||||
B b;
|
||||
b.call(1, fun);
|
||||
}
|
||||
};
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
MainWindow w;
|
||||
w.show();
|
||||
// Test test;
|
||||
// test.bind();
|
||||
|
||||
qDebug("local ip=%s",syscfg()->local_ip);
|
||||
|
||||
return app.exec();
|
||||
}
|
Reference in New Issue
Block a user