如果我要从一个类继承,我是否必须定义它的所有虚函数和纯虚函数?
例如,我有一个继承自QAbstractItemModel
. QAbstractItemModel
具有以下纯虚函数。如果我的派生类不打算使用index()
andparent()
方法,我需要实现它吗?
//qabstractitemmodel.h
virtual QModelIndex index(int row, int column,
const QModelIndex &parent = QModelIndex()) const = 0;
virtual QModelIndex parent(const QModelIndex &child) const = 0;
virtual int rowCount(const QModelIndex &parent = QModelIndex()) const = 0;
virtual int columnCount(const QModelIndex &parent = QModelIndex()) const = 0;
virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const = 0;