As far as I can tell the QException class will have a default copy constructor. The implementation of QUnhandledException in the standard library does exactly what the docs describe.
Your BeziExcept code declares a conversion constructor (roughly looks like a copy constructor but does not have the requisite signature) but does not provide an implementation. Is that the error you see? Since the members are all basic types you could probably just omit line 4 altogether and rely on the default copy constructor, or you could implement it explicitly:
#include <QtCore>
#include <QDebug>
class BeziExcept: public QException {
public:
// default and conversion constructor
BeziExcept(int num = 0):
exceptNumber(num),
pointNumber{0, 0}
{
}
// Copy constructor
BeziExcept(const BeziExcept &a) {
exceptNumber = a.exceptNumber;
pointNumber[0] = a.pointNumber[0];
pointNumber[1] = a.pointNumber[1];
}
int exceptNumber;
int pointNumber[2];
void raise() const
{
throw *this;
}
BeziExcept *clone() const
{
return new BeziExcept(*this);
}
};
int main(int argc, char **argv) {
BeziExcept a(314);
qDebug() << "a" << a.exceptNumber;
BeziExcept b(a);
qDebug() << "b" << b.exceptNumber;
BeziExcept *c = b.clone();
qDebug() << "c" << c->exceptNumber;
return( 0 );
}
#include <QtCore>
#include <QDebug>
class BeziExcept: public QException {
public:
// default and conversion constructor
BeziExcept(int num = 0):
exceptNumber(num),
pointNumber{0, 0}
{
}
// Copy constructor
BeziExcept(const BeziExcept &a) {
exceptNumber = a.exceptNumber;
pointNumber[0] = a.pointNumber[0];
pointNumber[1] = a.pointNumber[1];
}
int exceptNumber;
int pointNumber[2];
void raise() const
{
throw *this;
}
BeziExcept *clone() const
{
return new BeziExcept(*this);
}
};
int main(int argc, char **argv) {
QCoreApplication app(argc, argv);
BeziExcept a(314);
qDebug() << "a" << a.exceptNumber;
BeziExcept b(a);
qDebug() << "b" << b.exceptNumber;
BeziExcept *c = b.clone();
qDebug() << "c" << c->exceptNumber;
return( 0 );
}
To copy to clipboard, switch view to plain text mode
Bookmarks