I just got feedback from a C++ assignment that I did, and I sorta made a foolish mistake. This was the feedback I got from the student assistant:
Bank::Bank()
{
account_list = AccountList();
// What is happening here is that first the default constructor is called, because
// no explicit call is made beforehand. Then you OVERWRITE the already created
// AccountList with a temporary new one (which happens to be idential).
}
Yeah I know.......I had another class called AccountList that initialized itself automatically when i called the Bank() constructor, simply by virtue of the fact that I had an AccountList object in my private variable section.
Now doing it the way I did would me result in creating the AccountList object twice and then rewiting the original value.....with the same results. Well, we get the same answer, but its not good to screw around creating redundant objects.
And the second student assistant, advised me to do it the way I did it, oh well, we learn everyday.
Tuesday, May 22, 2007
Subscribe to:
Post Comments (Atom)
1 comment:
baby i didnt even finish reading it
Post a Comment