[Qt-interest] 'undefined reference' error for custom getter methods

Deepak Angeshwar angeshwar at gmail.com
Tue Sep 8 11:57:08 CEST 2009


All,

I am getting a undefined reference error when I build my project the error
points to one of the getter methods in my class.
I checked the .pro fie and can confirm that header file is added under
HEADERS section and the cpp has been added SOURCES

//setting some value and testing it in qDebud
quoteObject->setType("Whatever");
qDebug() << "Type:" << quoteObject->getType();


Error while building is

client.cpp:105: undefined reference to `Quote::getType() const'

//quote.h

#ifndef QUOTE_H
#define QUOTE_H

#include <QObject>
class Quote : public QObject
{
public:
void setType(QString type);
void setInstrument(QString instrument);
QString getType() const;
QString getInstrument() const;

private:
QString Type;
QString Instrument;
};

#endif // QUOTE_H


//quote.cpp

#include "quote.h"

void Quote::setInstrument(QString instrument){
Instrument = instrument;
}

void Quote::setType(QString type){
Type = type;
}



Can anyone point out what i am missing
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090908/dab1d3f8/attachment.html 


More information about the Qt-interest-old mailing list