NObody is goign to sit down and document an app for you: Do you have any idea how much work explaining code line by line is?
Every single line needs a paragraph of explanation! For example:
int next = r.Next();
Create a new variable called "next" which can hold a integer value. From the previously declared Random instance "r", call the "Next" method to get a new random number, and assign it to the "next" variable.
Can you imagine how long it would take us to explain even a very short code fragment like your example, line by line?
No. It is not going to happen. If you have a specific problem, then ask a question about it. But think first - would you want to sit down for 45 minutes and type up a line-by-line description for no good reason?
Quote:
I actually don't understand a few specific parts of the code not all of it. I afraid that you don't understand it if I just post the specific part. What I am trying to ask is why do we need to use reinterpret_cast<char *=""> (&ac), sizeof(account))? What does it do?
Start here:
ostream::write - C++ Reference[
^] and you'll find that ostream only supports one signature - it expects two parameters: a string to write and a count of the number of characters to write.
But what you are writing isn't a string: it's a class instance - so the
reinterpret_cast
tells the system to treat the
account
object as if it was a string so the function can be called:
reinterpret_cast conversion - cppreference.com[
^]
To be honest, it's a cheat, and if you use that code it'll probably come back to bite you later, and hard: if you expand or otherwise alter your
Account
class your data file will be useless, and there are variable types you could add to your class that will never work using that code.
Frankly, that code looks like someone grabbed chunks from a couple of dozen different student homework projects and bodged round the failures until they could hand it in: it's extremely poor quality. If you fished that out of the internet, I'd throw it back and run away screaming if I was you!