Welcome! Log In Create A New Profile

Advanced

Assignment2...Please help

Posted by BlaXpydo 
Announcements Last Post
Announcement SoC Curricula 09/30/2017 01:08PM
Announcement Demarcation or scoping of examinations and assessment 02/13/2017 07:59AM
Announcement School of Computing Short Learning Programmes 11/24/2014 08:37AM
Announcement Unisa contact information 07/28/2011 01:28PM
Assignment2...Please help
August 31, 2010 09:47AM
I hav declared my AccountList as this

class AccountList: public QList<Account*>
{
}

But how do I access the accounts in the list then? Its not making sense, and I can't find any way to get to them.

I hope someone can help.

_______________________________________
Don't be different...be the one making a difference
avatar Re: Assignment2...Please help
August 31, 2010 03:33PM
Greetz BlaXpydo

Your class AccountList is derived from QList<T*>
this means it contains pointers of type T.
In this case it T is Account a class.

Because AccountList is derived from QList it just needs a loop to iterate through each item.

I used

Language: C++
foreach (Account *acc, *this) { //statments }

You could use any of the Mutliating iterator loops given in chapter 4 like

Language: C++ (QT)
for (QStringList::iterator it = list.begin(); it != list.end(); ++it) { QString current = *it; qDebug() << "[[" << current << "]]"; }   //while loop with iterator QListIterator<QString> itr (list2); while (itr.hasNext()) { QString current = itr.next(); qDebug() << "{" << current << "}"; }

I hope this helps.
Re: Assignment2...Please help
August 31, 2010 04:55PM
Thanks for the help toxic, but I'm still confused. m_AcctNum is still private...how do I access it?

_______________________________________
Don't be different...be the one making a difference
Re: Assignment2...Please help
August 31, 2010 05:36PM
What I did do was to create a get function in class Account, but I don't think this is right.

_______________________________________
Don't be different...be the one making a difference
Re: Assignment2...Please help
September 01, 2010 10:36AM
Ok, so i got most of the stuff to work, but on question 2.......how do i change the textedit? My slot won't work.

_______________________________________
Don't be different...be the one making a difference
Sorry, only registered users may post in this forum.

Click here to login