So, I’m reading this book: C++ GUI Programming with Qt 4, Second Edition by Jasmin Blanchette; Mark Summerfield, in order to learn GUI programming. And while following thew book’s steps to create a simple spreadsheet application I get an “undefined reference”
error when I try to compile the Spreadsheet widget.
All the errors seem to be originated from the Cell *Spreadsheet::cell(int row, int column) function:
Cell *Spreadsheet::cell(int row, int column) const
{
return static_cast<Cell *>(item(row, column));
}
This is the first function that complains from spreadsheet.cpp
QString Spreadsheet::formula(int row, int column) const {
Cell *c = cell(row, column);
if (c) {
return c->formula();
} else {
return "";
}
}
Where the line Cell *c = cell(row, column); Sends the error: /home/axel/QtSDK/Code/Spreadsheet/spreadsheet.cpp:-1: error: undefined reference to `Cell::Cell()’
This keeps happening everywhere that cell(row, column) is called. The function in itself is defined in the spreadhseet header in the private section as: Cell *cell(int row, int column) const;
Sorry if it seems messy I’m kinda new to C++ programming.
Here’s my .pro file
TEMPLATE = app
CONFIG += console
CONFIG += qt
SOURCES += main.cpp \
spreadsheet.cpp
HEADERS += \
spreadsheet.h
If I’m missing something I’ll add it as soon as I can.
Thanks,
Axel
Definition of the
Cellclass is absent. It should becell.hat least and it should be included in spreadsheet.cpp or its code could be directly included inspresheed.hor.cppwhich is less probable. Anyway the error means missing of theCellconstructor.