Ok so I figured out it happens when you overload some different conversion functions;
Any solution to that? I wanna be able to easily output to multiple formats.
convertable.h
#ifndef CONVERTABLE_H
#define CONVERTABLE_H
#include <QString>
class Convertable
{
private:
int i;
public:
Convertable
(int in
=0,
const QString string
= QString()):c_string
(string
),i
(in
) {}
operator int()
{
return i;
}
{
return c_string;
}
};
#endif // CONVERTABLE_H
#ifndef CONVERTABLE_H
#define CONVERTABLE_H
#include <QString>
class Convertable
{
private:
int i;
QString c_string;
public:
Convertable(int in=0, const QString string = QString()):c_string(string),i(in) {}
operator int()
{
return i;
}
operator QString()
{
return c_string;
}
};
#endif // CONVERTABLE_H
To copy to clipboard, switch view to plain text mode
main.cpp
#include <QCoreApplication>
#include "convertable.h"
#include <QDebug>
{
return in1 + ": " + in2;
}
int main(int argc, char *argv[])
{
Convertable B("something");
qDebug() << toString(A,B);
return a.exec();
}
#include <QCoreApplication>
#include "convertable.h"
#include <QDebug>
QString toString(const QString &in1, Convertable &in2)
{
return in1 + ": " + in2;
}
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QString A("Print");
Convertable B("something");
qDebug() << toString(A,B);
return a.exec();
}
To copy to clipboard, switch view to plain text mode
Bookmarks