So, the typos are fixed and some other things too.
But now I'm having some trouble with an vTable error. And after searching the net for hours and trying over and over again I though it would be time to ask here.
This is a quote from http://www.storkyak.com/2006/07/gnu-...to-vtable.html
GNU C++: Undefined reference to 'vtable for
This is a linker error for GNU. If you get Undefined reference to 'vtable for className, it means that you declared but did not implement a virtual method. In my case, I declared a virtual destructor in the .h, but didn't implement it the .cpp.
So I thought that would be simple, just find the virtual method that I didn't implement in the subclass.
But I can't find it!
I even tried this, I removed OrderAddRecord.h and linked orderAddRecord.cpp to AbstractOrderRecord.h and I removed every virtual function and copied the private variables from orderAddRecord.h into AbstractOrderRecord.h. I changed the constructor in orderAddWindow.cpp.
But that doesn't work neither.
This is AbstractOrderRecord.h
#ifndef ORDERRECORD_H
#define ORDERRECORD_H
#include <QObject>
struct article {
QString description, customization, nr;
int ordered, delivered;
float price;
};
{
Q_OBJECT
public:
//set methods
virtual void setOrderId(const int);
virtual void setCid(const int);
virtual void setDeadline
( QDate* );
virtual void setPrepayment(const float);
virtual void setPreviousState(const int);
virtual void setCurrentState(const int);
virtual void addArticle(QList<article>);
//accessors
virtual int getOrderId();
virtual int getCid();
virtual QDate getDeadline
();
virtual float getPrepayment();
virtual int getPreviousState();
virtual int getCurrentState();
virtual article getArticle(int);
};
#endif
#ifndef ORDERRECORD_H
#define ORDERRECORD_H
#include <QObject>
class QDate;
class QStringList;
class QString;
struct article {
QString description, customization, nr;
int ordered, delivered;
float price;
QDate *warrentyDate;
};
class OrderRecord : public QObject
{
Q_OBJECT
public:
//set methods
virtual void setOrderId(const int);
virtual void setCid(const int);
virtual void setDeadline( QDate* );
virtual void setPrepayment(const float);
virtual void setPreviousState(const int);
virtual void setCurrentState(const int);
virtual void addArticle(const QString, const QString, const QString, const float, const int, const int, QDate*);
virtual void addArticle(QList<article>);
//accessors
virtual int getOrderId();
virtual int getCid();
virtual QDate getDeadline();
virtual float getPrepayment();
virtual int getPreviousState();
virtual int getCurrentState();
virtual article getArticle(int);
};
#endif
To copy to clipboard, switch view to plain text mode
This is orderAddRecord.h
#ifndef ORDERADDRECORD_H
#define ORDERADDRECORD_H
#include "AbstractOrderRecord.h"
class OrderAddRecord : public virtual OrderRecord {
Q_OBJECT
public:
void setOrderId(const int);
void setCid(const int);
void setDeadline
(QDate*);
void setPrepayment(const float);
void setPreviousState(const int);
void setCurrentState(const int);
void addArticle(const QList<article>);
//accessors
int getOrderId();
int getCid();
float getPrepayment();
int getPreviousState();
int getCurrentState();
article getArticle(int);
private:
int orderId;
int cid;
float prepayment;
int previousState;
int currentState;
QList<QVariant> *articles;
};
#endif
#ifndef ORDERADDRECORD_H
#define ORDERADDRECORD_H
#include "AbstractOrderRecord.h"
class QDate;
class QVariant;
class OrderAddRecord : public virtual OrderRecord {
Q_OBJECT
public:
OrderAddRecord(QWidget *parent);
void setOrderId(const int);
void setCid(const int);
void setDeadline(QDate*);
void setPrepayment(const float);
void setPreviousState(const int);
void setCurrentState(const int);
void addArticle(const QString, const QString, const QString, const float, const int, const int, QDate*);
void addArticle(const QList<article>);
//accessors
int getOrderId();
int getCid();
QDate getDeadline();
float getPrepayment();
int getPreviousState();
int getCurrentState();
article getArticle(int);
private:
int orderId;
int cid;
QDate *deadline;
float prepayment;
int previousState;
int currentState;
QList<QVariant> *articles;
};
#endif
To copy to clipboard, switch view to plain text mode
This is orderAddRecord.cpp
#include "orderAddRecord.h"
#include <QtCore>
OrderAddRecord
::OrderAddRecord(QWidget *parent
){
qDebug("OrderAddRecord::OrderAddRecord(): constructing");
}
void OrderAddRecord::setOrderId(const int orderId)
{
this->orderId = orderId;
}
void OrderAddRecord::setCid(const int cid)
{
this->cid = cid;
}
void OrderAddRecord
::setDeadline(QDate *deadline
) {
this->deadline = deadline;
}
void OrderAddRecord::setPrepayment(const float amount)
{
this->prepayment = amount;
}
void OrderAddRecord::setPreviousState(const int state)
{
this->previousState = state;
}
void OrderAddRecord::setCurrentState(const int state)
{
this->currentState = state;
}
void OrderAddRecord::addArticle(QList<article> art)
{
//this->articles << art;
}
void OrderAddRecord
::addArticle(const QString description,
const QString nr,
const QString customization,
const float price,
const int delivered,
const int ordered,
QDate *warrentyDate
) {
article tmpArticle;
tmpArticle.description = description;
tmpArticle.nr = nr;
tmpArticle.customization = customization;
tmpArticle.price = price;
tmpArticle.delivered = delivered;
tmpArticle.ordered = ordered;
tmpArticle.warrentyDate = warrentyDate;
//this->articles << tmpArticle;
}
int OrderAddRecord::getCid()
{
return this->cid;
}
int OrderAddRecord::getOrderId()
{
return this->orderId;
}
QDate OrderAddRecord
::getDeadline() {
// return this->deadline;
}
float OrderAddRecord::getPrepayment()
{
return this->prepayment;
}
int OrderAddRecord::getPreviousState()
{
return this->previousState;
}
int OrderAddRecord::getCurrentState()
{
return this->currentState;
}
article OrderAddRecord::getArticle(int index)
{
}
#include "orderAddRecord.h"
#include <QtCore>
OrderAddRecord::OrderAddRecord(QWidget *parent)
{
qDebug("OrderAddRecord::OrderAddRecord(): constructing");
}
void OrderAddRecord::setOrderId(const int orderId)
{
this->orderId = orderId;
}
void OrderAddRecord::setCid(const int cid)
{
this->cid = cid;
}
void OrderAddRecord::setDeadline(QDate *deadline)
{
this->deadline = deadline;
}
void OrderAddRecord::setPrepayment(const float amount)
{
this->prepayment = amount;
}
void OrderAddRecord::setPreviousState(const int state)
{
this->previousState = state;
}
void OrderAddRecord::setCurrentState(const int state)
{
this->currentState = state;
}
void OrderAddRecord::addArticle(QList<article> art)
{
//this->articles << art;
}
void OrderAddRecord::addArticle(const QString description, const QString nr, const QString customization, const float price, const int delivered, const int ordered, QDate *warrentyDate)
{
article tmpArticle;
tmpArticle.description = description;
tmpArticle.nr = nr;
tmpArticle.customization = customization;
tmpArticle.price = price;
tmpArticle.delivered = delivered;
tmpArticle.ordered = ordered;
tmpArticle.warrentyDate = warrentyDate;
//this->articles << tmpArticle;
}
int OrderAddRecord::getCid()
{
return this->cid;
}
int OrderAddRecord::getOrderId()
{
return this->orderId;
}
QDate OrderAddRecord::getDeadline()
{
// return this->deadline;
}
float OrderAddRecord::getPrepayment()
{
return this->prepayment;
}
int OrderAddRecord::getPreviousState()
{
return this->previousState;
}
int OrderAddRecord::getCurrentState()
{
return this->currentState;
}
article OrderAddRecord::getArticle(int index)
{
}
To copy to clipboard, switch view to plain text mode
This is a piece of orderAddWindow.cpp
OrderRecord *record = new OrderAddRecord(this);
OrderRecord *record = new OrderAddRecord(this);
To copy to clipboard, switch view to plain text mode
I tried this too.
OrderAddRecord *record = new OrderAddRecord(this);
OrderAddRecord *record = new OrderAddRecord(this);
To copy to clipboard, switch view to plain text mode
And this is de compiler error:
"vtable for OrderRecord", referenced from:
__ZTV11OrderRecord$non_lazy_ptr in orderAddRecord.o
"vtable for OrderAddRecord", referenced from:
__ZTV14OrderAddRecord$non_lazy_ptr in orderAddRecord.o
Does somebody know how to solve this.
Or where I can read some tutorials to solve this by myself?
Thanks,
Cyberboy
P.S. I'm currently busy with this online book :http://www.icce.rug.nl/documents/cpl...cplusplus.html
Bookmarks