title: Calling argument in parametrized constructor in method - C++
body: <p>I'm new at programming. I wondered if you were to call a specific argument in the parameter for your constructor, which you had to use in your method, then how would you do it with pointers? I solved it by the use of 'this' because the local variable name is the same as the member variable's name, but I just wanted to see how it is possible by the use of normal pointers and not the this pointer.</p>
  
  <p>Here is the code I worked on.</p>
  
  <p>BMR.h</p>
  
  <pre><code>#include &lt;string&gt;
  using namespace std;
  
  class BMR
  {
  public:
      BMR();
      BMR(char, int, int, int);
      int calculateBMR();
  
  private:
      int weight;
      int height;
      int age;
      char gender;
  };
  </code></pre>
  
  <p>BMR.cpp</p>
  
  <pre><code>#include "BMR.h"
  #include &lt;iostream&gt;
  
  using namespace std;
  BMR::BMR()
  {
  
  }
  
  BMR::BMR(char k, int h, int w, int a)
  {
     gender = k;
     height = h;
     weight = w;
     age = a;  
  }
  
  int BMR::calculateBMR()
  {
      int BMR;
      if(this-&gt;gender == 'M')
      {
          BMR = 10 * weight + (6.25 * height - (5*age)) + 5;
          cout &lt;&lt; "Man: " &lt;&lt; BMR &lt;&lt; endl;
      }
  
      if(this-&gt;gender == 'W')
      {
          BMR = 10 * weight + (6.25 * height - (5*age)) - 161;
          cout &lt;&lt; "Woman: " &lt;&lt; BMR &lt;&lt; endl;
      }
  }
  </code></pre>