Msg to Lauren Buecker, Can't reply to your thread

Hi Lauren,

For some reason I cannot reply to your thread, CPP was down for me earlier, maybe it was something to do with that.

It's a bit awkward, but I will reply here, for now.

Can I have two different classes in the account.h file. I do have to have a bankingsystem class.



I would never put 2 class headers in the same file. It's possible to do it, but much more organised for each class to have their own header and cpp files.

When you say you have to have a bankingsystem class - I am wondering about that a little. I am not disagreeing with you (it may have been specified in your assignment), it's just that you had a bankingsystem.cpp file with main() in it to start with. Is there some confusion about what's in each file? As I was going on about earlier, there is an application cpp that has main() in it (possibly bankingsystem.cpp) , then a .h and .cpp file for each class

Ok, If you do have to have a bankingsystem class that is fine. I presume this will hold the list of all the accounts and the services that deal with accounts as a whole - CreateAcct, DeleteAcct, FindAcct etc.

I guess I was trying to keep things simple by putting everything in one class. This sort of problem can be extended / complicated in lots of ways. Eg you could have classes for people, transactions, multiple accts, multiple banks etc.

Now that you are going to have the bankingsystem class (Maybe Bank is a better name), it will alter the account class quite a bit. It will now be just the account itself - Acct name, Balance, PassCode with functions that need to deal with the details like Deposit, Withdraw, CheckPassCode. StartBalance isn't really necessary as a member variable, it is just an argument that is used to set the Balance initially. Soon we will have to discuss Constructors, but I think you have enough to do for now as it is.

Any way hope it is all going well, and my info has been helpful to you :D

Let us know, how you go.

I was not able to post to the other thread regarding this program. I am in the same class working on the same project and have been following this thread to see if it could help me with issues I am having in my own code. I have 5 files in total, Account.h, Account.cpp, BankingSystem.h, BankingSystem.cpp and the test driver program, simply, test.cpp.

My int main () is in the test.cpp and none of the other files. My BankingSystem.cpp has

#include "BankingSystem.h"
#include "Account.h"

We are required to use this piece of code and I believed it to go in the BankingSystem.h file:

private:
vector <Account>accounts_;

I am not fond of the book we use for the class..it is Deitel and from the reviews I have read on the Internet, it is not the best book. I am going to purchase the C++ Primer by Lippman to try to help me understand the language better. That being said, I am still working on this program and this is the error I am getting at the moment:


1>c:\users\kelly\documents\visual studio 2008\projects\mybankingsystem\mybankingsystem\test.cpp(40) : error C3867: 'BankingSystem::addNewAccount': function call missing argument list; use '&BankingSystem::addNewAccount' to create a pointer to member


If I use the argument as suggested with the &..the program starts to compile then I get linker errors..which is what I am researching now:

1>Linking...
1>Account.obj : error LNK2019: unresolved external symbol "public: void __thiscall Account::setBalance(double)" (?setBalance@Account@@QAEXN@Z) referenced in function "public: __thiscall Account::Account(int,int,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,double)" (??0Account@@QAE@HHV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@0N@Z)
1>BankingSystem.obj : error LNK2001: unresolved external symbol "public: void __thiscall Account::setBalance(double)" (?setBalance@Account@@QAEXN@Z)

I am not exactly comfortable with all of the code, I follow the book and try to use bits and pieces of examples to accomplish what this program is trying to accomplish given the material we have been taught (somewhat since it is distance learning there are no lectures..just 'read the book' and 'do the exercises'.

Any hints or suggestions on the above error is appreciated.
could you show us the whole code? if you don't want your classmates copying it, just PM it to me
Lauren,

Maybe you could start a new thread, seen as we can't seem to post to your original one? That way it will show up in your "My Topics" list.

If you want you could PM your code to me, that way Zephilinox can help krmfsu, and I can help you. You would have to set up your PM so I can reply to you, otherwise I would have to give clues here rather than any code. Clues are what I would normally give anyway (it's your assignment), but sometimes code snippets can be very helpful. Up to you. You could also PM Volatile Pulse, as he has been helping too. Hopefully we say the same things !! :-D Otherwise we could all post to your new thread, but try not give the whole game away.

krmfsu wrote:
We are required to use this piece of code and I believed it to go in the BankingSystem.h file:

private:
vector <Account>accounts_;


Ok, that answers the question I was asking Lauren. So BankingSystem class could have functions that deal with accts as a whole - AddAcct, DeleteAcct, FindAcct. The Account class could have functions that deal with one acct details.
Edit:
It also shows where the underscore in variables is coming from, I am sure the teacher won't mind if you all use a different variable name - the point was they want you to use a vector of accts.



krmfsu wrote:
I am not fond of the book we use for the class.


Text books are often not very good. They purposely have trivial examples, so that the reader can see what the particular feature is for, without blowing them away with something really hard. Other problems are that they show code all in one file with function code inline. This leads the reader into thinking that this is how it is always done - when the reality is that each class should have it's own .h & .cpp files and an application file that has main() in it. Students then run into all kinds of trouble trying to extend the examples.

Often the problem is that people rush through learning the basics of C programming first - The book gives a whirlwind tour of C, then students tear into writing C++ code without really knowing what's going on. Often people start with writing C code but use cout, cin, maybe bool - that's fine (everyone has to start with something - I did that myself, initially). The thing is that C++ is really very different to C.

An example might be a problem to count the number of occurrences of a particular character in a string. The C approach would be to go through the array of chars (that is what a string is, in C), compare each one with the search char and increment the count when one is found. There might be a library function somewhere that does the same thing. The C++ approach is to use the count algorithm on the string - it's just a function that gives you the answer straight up. A C++ string is an array of chars too, but it has all kinds of functionality built in. The C++ algorithms works on all kinds of different objects, not just strings.

What sometimes happens is people mix the C & C++ approaches - I have seen someone use a for loop to process each char in a string and then they had a count algorithm in the body of the for loop as well.

My experience was that my book explained classes and a bit of inheritance, and all the other things, but it didn't help with class design, probably because that is a whole subject on it's own, so presumably one could get another book to read all about it.

The thing is, books can't cover everything, probably already 500 -1000 pages - that's just to explain the basics. Having said all this, some books might be better than others.

Last edited on
Ya I was having a bit of trouble doing that myself. But it works on occasion I wonder what could be wrong with it and why firefox is having a problem.
KRMFSU ya, are you doing the class distance learning? i am and it is kinda hard.
Apparently, Ctrl-Shift-R reloads the page, bypassing the cache. Learnt this today from helios. So we could all post to your original thread now, hopefully.
Topic archived. No new replies allowed.