title: Operator overloading >> cin
body: <p>I need to overload the &lt;&lt; and >> operators, but I don't see any errors.
  When i overloaded only operator &lt;&lt; and initialize the object in main directly.
  I don't receive any error. But when i overloaded operator >>, I don't see any pop up to enter the variables for the object.
  Here is the code and I don't seem to find what's wrong with it</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string.h&gt;
  #include &lt;assert.h&gt;
  using namespace std;
  class vehicle
  {
  protected:
      int number, year, cost;
      char *make, *model, *bodyStyle, *color;
  public:
      vehicle(int = 0, int = 0, char* = NULL, char* = NULL, char* = NULL, char* = NULL, int = 0);
     ~vehicle();
      friend istream &amp;operator&gt;&gt;(istream&amp; stream,  vehicle&amp; v);
      friend ostream &amp;operator&lt;&lt;(ostream&amp; stream, const vehicle&amp; v);
  };
  vehicle::vehicle(int a, int b,  char* ma1, char* mod1, char* bs1, char* c1, int cos)
  {
      number = a;
      year = b;
  
      make = new char[strlen(ma1) + 1];
      assert(make);
      strcpy (make,ma1);
  
      model = new char[strlen(mod1) + 1];
      assert(model);
      strcpy(model,mod1);
  
      bodyStyle = new char[strlen(bs1) + 1];
      assert(bodyStyle);
      strcpy(bodyStyle,bs1);
  
      color = new char[strlen(c1) + 1];
      assert(color);
      strcpy(color,c1);
  
      cost = cos ;
  }
  vehicle::~vehicle()
  {
      delete[] make;
      delete[] model;
      delete[] bodyStyle;
      delete[] color;
  }
  istream&amp; operator&gt;&gt;(istream&amp; stream,  vehicle&amp; v)
  {
      stream&gt;&gt;v.number;
      stream&gt;&gt;v.year;
      stream&gt;&gt;v.cost;
      stream&gt;&gt;v.make;
      stream&gt;&gt;v.model;
      stream&gt;&gt;v.bodyStyle;
      stream&gt;&gt;v.color;
      return stream;
  }
  ostream&amp; operator&lt;&lt;(ostream&amp; stream, const vehicle&amp; v)
  {
      stream&lt;&lt;v.number&lt;&lt;endl;
      stream&lt;&lt;v.year&lt;&lt;endl;
      stream&lt;&lt;v.cost&lt;&lt;endl;
      stream&lt;&lt;v.make&lt;&lt;endl;
      stream&lt;&lt;v.model&lt;&lt;endl;
      stream&lt;&lt;v.bodyStyle&lt;&lt;endl;
      stream&lt;&lt;v.color&lt;&lt;endl;
      return stream;
  }
  
  class Truckvehicle : public vehicle
  {
      int passengers, mileage, grossWeight, tempGross;
      char *poweredBy;
      public:
      Truckvehicle(int = 0, int = 0, char* = NULL, char* = NULL, char* = NULL, char* = NULL, int = 0, int = 0, int = 0, int = 0, char * = NULL, int = 0);
      ~Truckvehicle();
      friend ostream &amp; operator&lt;&lt;(ostream&amp; stream, const Truckvehicle&amp; tv);
      friend istream &amp; operator&gt;&gt;(istream&amp; stream,  Truckvehicle&amp; tv);
  
  };
  
  Truckvehicle::Truckvehicle(int a, int b, char* ma1, char* mod1, char* bs1, char* c1, int cos, int pass1, int mil, int gross, char* pb, int tg) :
      vehicle(a, b, ma1, mod1, bs1, c1, cos), passengers(pass1), mileage(mil), grossWeight(gross), poweredBy(pb), tempGross(tg)
  {
      passengers = pass1;
      mileage = mil;
      grossWeight = gross;
  
      poweredBy = new char[strlen(pb) + 1];
      assert(poweredBy);
      strcpy(poweredBy, pb);
  
      tempGross = tg;
  }
  
  Truckvehicle :: ~Truckvehicle()
  {
      delete[] poweredBy;
  }
  istream&amp; operator&gt;&gt;(istream&amp; stream,  Truckvehicle&amp; tv)
  {
      stream&gt;&gt;tv.number;
      stream&gt;&gt;tv.year;
      stream&gt;&gt;tv.make;
      stream&gt;&gt;tv.model;
      stream&gt;&gt;tv.bodyStyle;
      stream&gt;&gt;tv.color;
      stream&gt;&gt;tv.cost;
      stream&gt;&gt;tv.passengers;
      stream&gt;&gt;tv.mileage;
      stream&gt;&gt;tv.grossWeight;
      stream&gt;&gt;tv.poweredBy;
      stream&gt;&gt;tv.tempGross;
  
      return stream;
  }
  ostream &amp; operator&lt;&lt;(ostream&amp; stream, const Truckvehicle&amp; tv)
  {
      stream&lt;&lt;tv.number&lt;&lt;endl;
      stream&lt;&lt;tv.year&lt;&lt;endl;
      stream&lt;&lt;tv.make&lt;&lt;endl;
      stream&lt;&lt;tv.model&lt;&lt;endl;
      stream&lt;&lt;tv.bodyStyle&lt;&lt;endl;
      stream&lt;&lt;tv.color&lt;&lt;endl;
      stream&lt;&lt;tv.cost&lt;&lt;endl;
      stream&lt;&lt;tv.passengers&lt;&lt;endl;
      stream&lt;&lt;tv.mileage&lt;&lt;endl;
      stream&lt;&lt;tv.grossWeight&lt;&lt;endl;
      stream&lt;&lt;tv.poweredBy&lt;&lt;endl;
      stream&lt;&lt;tv.tempGross&lt;&lt;endl;
  
      return stream;
  }
  int main()
  {
  Truckvehicle TV;
  //Read in the following values for TV (111111, 2014,"Toyota","Tacoma", "4X4", "Black",25000, 2, 15000,333333,"Gas", 222222);
  cin&gt;&gt;TV;
  cout&lt;&lt;TV;
  return 0;
  }
  </code></pre>