quty
28th August 2015, 12:04
Hi,
Ive got 2 classes and I would like Class2 to use the toString() of Class1, but Im getting the following error:
error: cannot call member function 'QString Process::toString() const' without object
.arg(Process::toString());
^
Class1:
QString Process::toString() const
{
return QString("Type: %1, Date: %2, Number: %3, Price: %4")
.arg(m_Type).arg(m_Date.toString("dd.MM.yyyy")).arg(m_NoOfItems).arg(m_PricePerItem);
}
Class2:
QString Items::toString() const
{
QString product = QString("Item process: %1\n")
.arg(Process::toString());
return process;
}
Please assist.
Ive got 2 classes and I would like Class2 to use the toString() of Class1, but Im getting the following error:
error: cannot call member function 'QString Process::toString() const' without object
.arg(Process::toString());
^
Class1:
QString Process::toString() const
{
return QString("Type: %1, Date: %2, Number: %3, Price: %4")
.arg(m_Type).arg(m_Date.toString("dd.MM.yyyy")).arg(m_NoOfItems).arg(m_PricePerItem);
}
Class2:
QString Items::toString() const
{
QString product = QString("Item process: %1\n")
.arg(Process::toString());
return process;
}
Please assist.