title: How to call constructors in main()?
body: <p>I'm working on a program that takes a <code>string</code> and a <code>int</code> as variables for my <code>friend</code> constructors.  I have most of my program done, but since I'm new to this topic of <code>friend</code>s and constructors with C++, I don't know how to implement the call on my <code>main()</code> to use these parameters and start working on my <code>istream</code> and <code>ostream</code> to ask the user to input
  the values and start printing it.</p>
  
  <p>Could someone please guide me the right way?</p>
  
  <p>These are my current constructors:</p>
  
  <pre><code>jellyBeanFlavors::jellyBeanFlavors()
  {
      flavor = "null";
      jellyBeans = 0;
  }
  
  jellyBeanFlavors::jellyBeanFlavors(int newJellyBeans)
  {
      flavor = "null";
      jellyBeans = newJellyBeans;
  }
  
  jellyBeanFlavors::jellyBeanFlavors(string newFlavor, int newjellyBeans)
  {
      flavor = newFlavor;
      jellyBeans = newjellyBeans;
  }
  
  void jellyBeanFlavors::output()
  {
      cout &lt;&lt; flavor &lt;&lt; " " &lt;&lt; jellyBeans &lt;&lt; endl;
  }
  </code></pre>
  
  <p>Now I'm trying to implement here my objects and start making my questions for input and then print with my <code>istream</code> function:     </p>
  
  <pre><code>int main ()
  
      {
          jellyBeanFlavors::jellyBeanFlavors(string newFlavor, int newjellyBeans);
  
          jellyBeanFlavors();
          jellyBeanFlavors myFirstFlavor = jellyBeanFlavors.the;
          jellyBeanFlavors mySecondFlavor;
          jellyBeanFlavors total = 0;
  
          cout &lt;&lt; "Your first flavor  is: "&lt;&lt; myFirstFlavor. &lt;&lt; endl;
          cin &gt;&gt; myFirstFlavor;
          cout &lt;&lt; "Your second flavor is: "&lt;&lt; mySecondFlavor &lt;&lt; endl;
          cin &gt;&gt; mySecondFlavor;
          cout &lt;&lt; "The expected result of adding" &lt;&lt; " the first flavor loaded with" &lt;&lt; mySecondFlavor &lt;&lt;" in the quantity with jellybean2 loaded with 6 in the quantity is: ";
          cout &lt;&lt; "a jellybean with a quantity of 11.
          cout &lt;&lt; "the result of adding jellybean1 and jellybean two is: " &lt;&lt; jellybean1 + jellybean2 &lt;&lt; endl;
  
  
          // this isnt implemented right but i need advice please on how to call my objects from my main class.
  
  
          system("pause");
  
          return 0;
      }
  </code></pre>
  
  <blockquote>
    <p>so you dont get confused here is my main class:</p>
  </blockquote>
  
  <pre><code>    #include &lt;iostream&gt;
      #include &lt;string&gt;
      using namespace std;
  
      class jellyBeanFlavors
      {
          friend jellyBeanFlavors operator + (jellyBeanFlavors theFirstJellyBean, jellyBeanFlavors theSecondJellyBean);//sums
          friend jellyBeanFlavors operator - (jellyBeanFlavors theFirstJellyBean, jellyBeanFlavors theSecondJellyBean);//(binary) substracts
          friend jellyBeanFlavors operator - (jellyBeanFlavors theFirstJellyBean);// (unary) checks negatives
          friend jellyBeanFlavors operator * (jellyBeanFlavors theFirstJellyBean,jellyBeanFlavors theSecondJellyBean);//multiplies
          friend jellyBeanFlavors operator / (jellyBeanFlavors theFirstJellyBean,jellyBeanFlavors theSecondJellyBean);//divides
          friend jellyBeanFlavors operator == (jellyBeanFlavors theFirstJellyBean,jellyBeanFlavors theSecondJellyBean);//compares
          friend jellyBeanFlavors operator &lt; (jellyBeanFlavors theFirstJellyBean,jellyBeanFlavors theSecondJellyBean);// less than
          friend jellyBeanFlavors operator &gt; (jellyBeanFlavors theFirstJellyBean,jellyBeanFlavors theSecondJellyBean);//greater than
          friend ostream&amp; operator &lt;&lt; (ostream&amp; outputStream, const jellyBeanFlavors&amp; jellyBeanOutput);// output
          friend istream&amp; operator &gt;&gt; (istream&amp; inputStream, jellyBeanFlavors&amp; jellyBeanInput);//input 
  
      public:
          jellyBeanFlavors();
          jellyBeanFlavors(int);
          jellyBeanFlavors(string, int);
          void output();
  
      private:
          string flavor;
          int jellyBeans;
  
      };
  </code></pre>
  
  <blockquote>
    <p><strong>> my solution to my program by adding objects and overloading
    them:</strong></p>
    
    <p>my solution to my program by adding objects and overloading them:</p>
  </blockquote>
  
  <pre><code> int main ()
      {   
          system("cls");
          char op;
          jellyBeanFlavors obj1,obj2,obj3;
          do{
              cin&gt;&gt;obj1;  //flavor
              cin&gt;&gt;obj2;  //amount 
  
              system("cls");
              cout&lt;&lt;"JELLYBEANS:"&lt;&lt;endl;
  
              obj3=obj1+obj2;
              cout&lt;&lt;"\n The Sum is : ";
              obj3.output();
  
              obj3=obj1-obj2;
              cout&lt;&lt;"\n The Substraction is : ";
              obj3.output();
  
              obj3=obj1*obj2;
              cout&lt;&lt;"\n The Multiplication is: ";
              obj3.output();
  
              obj3=obj1/obj2;
              cout&lt;&lt;"\n The Divide operation is : ";
              obj3.output();
  
              cout&lt;&lt;"\n"; 
              obj3 = obj1==obj2;
              obj3.output();
              cout&lt;&lt;"\n";
  
              obj3 = obj1&gt;obj2;
              obj3.output();
              cout&lt;&lt;"\n";
  
              obj3 = obj1&lt;obj2;
              obj3.output();
              cout&lt;&lt;"\n";
  
              obj3 = -obj1;
              obj3.output();
              cout&lt;&lt;"\n";
  
              obj3 = -obj2;
              obj3.output();
              cout&lt;&lt;"\n";
  
              cout&lt;&lt;"\n\nPress A/a and Enter to continue or 0 to exit"&lt;&lt;endl;
              cin&gt;&gt;op;
              if(op = 0)
              {
                  exit(0);
              }
          }while(op =='a'|| op=='A');
  
  
          system("pause");
      }
  </code></pre>