title: Can't return value from a function call to main() correctly
body: <p>I am trying to test this simple function, but Opt.status, Opt.Year values are not returned back to main(). Why? Please help as I am new to C++.I am using visual c++ to execute these codes.This is in my .cpp file</p>
  
  <pre><code>#include "stdafx.h"
  #include "iostream"
  #include "conio.h"
  #include "stdio.h"
  
  using namespace std;
  
  
  int main() 
  {
      Easy_Task obj_EasyTask;
      TimeDateMonthOptions whatOptions=DATE;
      TOptions Opt;
      Opt.status=FALSE;
      Opt.Year=1970;
  
      printf("Enter code\n");
      scanf("%d",&amp;obj_EasyTask.code);
  
      cout &lt;&lt; "the code entered is: " &lt;&lt; obj_EasyTask.code;
      obj_EasyTask.display2(obj_EasyTask.code);
  
      cout &lt;&lt; "\nOutput: " &lt;&lt; obj_EasyTask.show();
  
      printf("\nEnter the options that you prefer\n");
      scanf("%d",&amp;whatOptions);
  
  
      obj_EasyTask.display3(whatOptions, Opt);
  
      cout &lt;&lt; "\nOpt.Year: " &lt;&lt; Opt.Year;
  
      if(Opt.status)
      {
          obj_EasyTask.x=(Opt.Year)&amp; 0x00FF;
          obj_EasyTask.y=((Opt.Year)&amp; 0xFF00)&gt;&gt;8;
          cout &lt;&lt; "\nX: " &lt;&lt; obj_EasyTask.x;
          cout &lt;&lt; "\nY: " &lt;&lt; obj_EasyTask.y;
          obj_EasyTask.Result=(obj_EasyTask.x)*(obj_EasyTask.y);
      }
  
  
      char holdWindow;
      std::cin &gt;&gt; holdWindow;
      return 0;
  }
  
  
  uint16_t Easy_Task::display2(uint16_t code) 
  {
      if(code==1)
      {
          c = 7;
      }
      else
      {
          c = 9;
      }
      return c;
  
  }
  
  uint16_t Easy_Task::display3(TimeDateMonthOptions whtOptions, TOptions Opt)
  {
      switch(whtOptions)
      { 
          case 0:
          case 1:
          case 2:
          case 3:
              Opt.status=TRUE;
              cout &lt;&lt; "\nStatus1: " &lt;&lt; Opt.status;
              Opt.Year=1991;
              cout &lt;&lt; "\nYear1: " &lt;&lt; Opt.Year;
          break;
          case 7: 
              Opt.status=FALSE;
              cout &lt;&lt; "\nStatus2: " &lt;&lt; Opt.status;
              Opt.Year=2013;
              cout &lt;&lt; "\nYear2: " &lt;&lt; Opt.Year;
          break;
          default:
              Opt.status=FALSE;
              cout &lt;&lt; "\nStatus3: " &lt;&lt; Opt.status;
              Opt.Year=2010;
              cout &lt;&lt; "\nYear3: " &lt;&lt; Opt.Year;
          break;
  
      }
      return Opt.status, Opt.Year;
  
  }
  </code></pre>
  
  <p>In my .h file I have the class defined as follows:</p>
  
  <pre><code>#pragma once
  
  #include "targetver.h"
  #include &lt;stdio.h&gt;
  #include &lt;tchar.h&gt;
  
  typedef unsigned short uint16_t;
  
  #define TRUE 1;
  #define FALSE 0;
  
  
  typedef struct TOptions
  {
      bool status;
      uint16_t Year;
  };
  
  typedef enum 
  {
      YEAR,
      MONTH,
      DATE,
      HOURS,
      MINUTES,
      SECONDS,
      HUNDRETHS,
      UNDEFINED
  }TimeDateMonthOptions;
  
  
  class Easy_Task
  {
  public:
  
      uint16_t code, c, x,y, Result;
      uint16_t display2(uint16_t code);
  
      uint16_t show()
      {
  
          return c;
      };
  
      uint16_t display3(TimeDateMonthOptions whatOptions, TOptions Opt);
  
  };     
  </code></pre>
  
  <p>The problem I have is line:
          if(Opt.status)</p>
  
  <p>Where it doesn't return the value of 1 but instead in takes the default value which was defined earlier. Why is this happening?</p>