Hi, i am new to C++
I am creating a custom QList of type Account* called AccountList through inheritance.
My interface declaration for AccountList is as follows:
class Client
{
public:
Client(QString firstName, QString lastName, QString address1, QString address2, QString postalCode);
QString toString();
private:
QString m_FirstName;
QString m_LastName;
QString m_Address1;
QString m_Address2;
QString m_PostalCode;
};
class Account
{
public:
Account(unsigned acctNum, double balance, const Client owner);
unsigned getAcctNum();
double getBalance();
Client getOwner();
virtual ~Account();
private:
unsigned m_AcctNum;
double m_Balance;
Client m_Owner;
};
class AccountList : public QList<Account*>
{
public:
QString toString() const;
Account* findAccount(unsigned accNum) const;
bool addAccount(const Account* acc) const;
bool removeAccount(unsigned accNum) const;
};
I am having a problem with implementation of AccountList, e.g. the findAccount method.
Account* AccountList::findAccount(unsigned accNum) const
{
Account foundAccount;
foreach(Account* acc, this)
{
if (acc->getAcctNum() == accNum)
{
foundAccount = acc;
break;
}
}
return foundAccount;
}
Hope the above method gives you an idea of what i am trying to accomplish. Seems pretty simple and straigh forward, but i can't get it to work. Qt Creator compiler gives me all sorts of strange errors on compiling.
Any help would be appreciated.