title: function in class that multiplies 2 hidden variables
body: <blockquote>
    <p>Create a class with two variables as data members and create a member
    function to multiply it?</p>
  </blockquote>
  
  <pre><code> class Madina{
    int n1,n2 ;
  
   public:int getN1(){
     return n1 ;
   }
   public:int getN2(){
     return n2 ;
   }
   public:int setN1(int new_n1){
     n1 = new_n1 ;
   }
   public:int setN2(int new_n2){
     n2 = new_n2 ;
   }
  public:int func(){
    return n1*n2;
  }
  
  };
  
  
  int main(){
  
    Madina example ;
    int n1 =0;
    int n2 =0;
    cout &lt;&lt; "Input"&lt;&lt;endl ;
    cout &lt;&lt; "Enter 1st number"&lt;&lt;endl;
    cin &gt;&gt; n1 ;
    cout &lt;&lt; "Enter 2nd number"&lt;&lt;endl ;
    cin &gt;&gt; n2 ;
  
    example.setN1(n1);
    example.setN2(n2);
  
    cout &lt;&lt; "get n1 " &lt;&lt; example.getN1()&lt;&lt;endl;
    cout &lt;&lt; "get n2 " &lt;&lt; example.getN2()&lt;&lt;endl;
  
    cout &lt;&lt; "Output product is "&lt;&lt; example.func()&lt;&lt;endl ;
    return 0 ;
  
  
  }
  </code></pre>
  
  <p>I dont' know why the program just crashes.. without explaining anything!</p>