I had a look at your code and I noticed a few things to start with:
1.) You're falling into one of the common newbie traps of code:
Wrong. This is assigning 1 to choice which will always equate to true. This is a logical error and it won't be picked up by the compiler because it's syntactically correct. The code you want isCode:if ( choice = '1' ) { // do blah!!! }
This way you'll never miss the double = comparison time because you can't assign a value to a constant, but you can compare. Do it this way from now on and you'll save yourself (and anyone debugging your code) many hours.Code:if ('1' == choice) { // do blah!!! }
2.) You tried to execute a statement after returning from a function. Think about it. Does that look right? I took the liberty of ditching the last statement for you. The program now compiles and runs.
3.) You're sort of missing the point of OO programming. You should have a 'Person' or 'Customer' class not a *info class. OO programming is meant to encapsulate Data + Methods to work on the data. The object is not the data itself. Instances of an object contain data, the object class itself is just a blueprint for creating objects.Code:float userInfo::writeFile(ofstream &outF) { float newbal; //update = updateA; outF.is_open(); newbal=updateA() + Acc; outF << newbal; return Acc; // outF.close(); /* a statement after the function returns - wtf??? */ }
So you want a class, Person for example with attributes (private variables) and methods (public functions) to access those variables. readFile and writeFile are not methods that should act on an object of type Person. They should be either in their own class or in the main program. You should also create classes for all object that are involved in transactions such as Account, Customer etc.
4.) You're either using header files or you're not. Make up your mind. If you're going to use them, each .cpp file should have a corresponding .h file. Good header files should be written and commented so that an API user doesn't even have to look at the .cpp source. The header file should explain everything.
That's all for now kids.![]()




Reply With Quote