Need data hiding and inheritance features in my code

Thread Starter


Joined Mar 22, 2019
I am trying to implement my idea into coding

This is my attempt

using namespace std;

class Person
               int age;
               int weight;       
                char ID;
               int password;

int main ()
    class Person Object1;
    Object1.age = 20;
    Object1.weight = 40;
    cout<<"Age : "<<Object1.age<<endl;
    cout<<"Weight : "<<Object1.weight<<endl;
    return 0;
I think It might be more meaningful. I want to add the data hiding features in code. I would create new class of student from person class.

I am not looking for a code I am looking idea how to add data hiding and inheritance to improve previous idea


Joined Oct 29, 2013
What do you mean by hiding?

This is probably more advanced than where you're at right now, but if you are going after real security then you should never store the password itself in memory. Instead you should store a hash of the password in encrypted memory, and overwrite the memory when you free it. Unless of course the purpose of your software is to store passwords for later retrieval, in which case you must store the password itself, but still use encrypted memory, be careful with the keys and overwrite the memory before you free it.


Joined Oct 29, 2013
I guess I should rephrase my question; are you hiding it from other programmers, so they won't be tempted to directly manipulate variables that they shouldn't, or hiding it from hackers who may be rummaging through memory looking for something interesting? I only ask because one of your variables is a password.

If you want to keep other programmers from fiddling with a variable directly, then just make it private and put a public set() and get() to manipulate the variable. Now programmers know not to fiddling with the variable directly. If you want to keep it hidden from hackers then that requires a different approach.