C Programming, Variables
<p>When we declare variables in a class and then when we assign the value of those variables, for example like this </p>

<pre><code>class c {

    public :

    int x;
    int x2;

    c () {
        x = 0;
        x2 = 0;

        scanf ("%d", &amp;x); and now we're gonna input for example 10
    } 
};
</code></pre>

<p>each time the class is used, I mean each time the constructor is called, the value of x becomes 0 again since it is initialized as zero in the constructor. However if we don't initialize the value, there will be errors.</p>

<p>My question is that how can we keep the value of the variable when we call the constructor again and again so that it doesn't become zero ?  </p>

<p>Edit:</p>

<pre><code>void example () {

int i;
scanf ("%d", &amp;i); 
switch (i) {
case 1 : {Object ob1; system ("cls"); menu ();} // this object contains a value like 20 
case 2 : {Object ob2; system ("cls"); menu ();} 
}  

}
</code></pre>

<p>There is another switch case in Object 1 which includes an option to go back to a main menu, now if I enter 1 again go back to object 1 I cannot see the value 20, it will be 0</p>
