I havent coded this yet so I dont have anything to show, I am trying to figure out how it would work first.
I am trying to work out how my functions will work in different classes that inherit from each other.
First I have a USER class which I think is called the parent class, which the other classes inherit from.
Next I have a GUEST class, and this class as i said inherits from the USER class, this class has a function called CREATEACCOUNT, and this CREATEACCOUNT function makes use of another function called ENCRYPT
The next class is called REG_USER, and this class also inherits from the USER class, this class has a function called LOGIN, and this LOGIN, function also makes use of the ENCRYPT function, the same one that CREATEACCOUNT uses
So im wondering how do I set this up. At first i was just going to code 2 encrypt functions in each of the classes, but that seems like it would be bad coding.
Do i put the encrypt function into the USER class and let it work through the inheritance?
a class should represent something and you should be able to make a mini conversation about it that is coherent.
Yes, that is my car, it has a radio and a v6 engine and can go from point at to point b and cooks waffles. Wait, what? Maybe void cookwaffles() should not be in the car class just because it was handy to inherit it into the waffleiron class. Hmm.
It sounds like encryption should either be simple / stand alone method (no class at all, inputs of something like a string and a public key or whatever) or its own class (could be for various reasons like construct with the public key and just pass in a string, or a running encryption of distinct streams where you need multiple streams at different places that need to be maintained rather than just a straight gigo function).
Back to the car analogy, inherited classes also tell a story, you may inherit that radio and engine and so on.
So tell the story. A guest is a user who has a password that is encrypted by a difficult to crack 1024 bit algorithm.
A guest is a user. Users encrypt their own password as part of their everyday job description, using a pocket calculator. :P
I am trying to be a little funny here. But you get the point? Is encryption something the user DOES (method) or HAS (variable)? No. They HAVE an encrypted password, but know nothing about how it was scrambled (at least you hope not, as that is the first step to cracking it).
I dont think I have come across standalone functions, my teaching has been very patchy. So My classes are over different cpp files, if I have this standalone function in its own cpp file, the functions in the classes will be able to access the standalone? I have started to code it up, so trying out this standalone version