title: C++ error: no match for 'operator<<' in '"Data for " << Rover::getName()()'
body: <p>I'm working on a bit of code for my C++ class, and I'm a bit stuck.</p>
  
  <p>Here's the bit of the assignment I'm working on:</p>
  
  <hr>
  
  <p>Within the Rover class, specify the following member instance variables:</p>
  
  <pre><code> name (String)
  
   x position on a grid (integer)
  
   y position on a grid (integer)
  
   direction by compass – N, S, E, or W (String)
  
   speed (0 – 5 meters per second, integer)
  </code></pre>
  
  <p>Within the Rover class, specify the following methods:</p>
  
  <pre><code> No-arg constructor – set the rover’s position to (0,0), its speed to 0, 
    its direction to North,and its name to Default
  
   Constructor that receives parameters to initialize all five 
    instance variables described above
  
   Setter methods for each instance variable
  
   Getter methods for each instance variable
  
   getRoverData – returns a string that displays values for each instance 
    variable of the current rover object, placing each value on a separate line, 
    as follows:
  </code></pre>
  
  <p>So right now I just want to get the base case to work. Here's the entirety of my code:</p>
  
  <hr>
  
  <p>main.cpp:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include "Rover.h"
  
  using namespace std;
  
  
  int main() {
  
      Rover rover1;
  
      rover1.setDefaultValues();
  
      cout&lt;&lt;rover1.getRoverData(rover1)&lt;&lt;endl;
  
      return 0;
  }
  </code></pre>
  
  <p>rover.cpp:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include "Rover.h"
  using namespace std;
  
  //put functions in here
  
  void Rover::setDefaultValues() {
      name = "Default";
      xcoord = 0;
      ycoord = 0;
      direction = "N";
      speed = 0;
  
  }
  
  void Rover::constructRover() {
  
  }
  
  void Rover::setXcoord(int xcoord) {
      this-&gt;xcoord = xcoord;
  }
  
  void Rover::setYcoord(int ycoord) {
      this-&gt;ycoord = ycoord;
  
  }
  
  void Rover::setName(string name) {
      this-&gt;name = name;
  }
  
  void Rover::setDirection(string direction) {
      this-&gt;direction = direction;
  }
  
  void Rover::setSpeed(int speed) {
      this-&gt;speed = speed;
  }
  
  int Rover::getXcoord() {
      return xcoord;
  
  }
  
  int Rover::getYcoord() {
      return ycoord;
  }
  
  string Rover::getName() {
      return name;
  }
  
  string Rover::getDirection() {
      return direction;
  }
  
  int Rover::getSpeed() {
      return speed;
  }
  
  string Rover::getRoverData(Rover rover) {
      string printStatement = "";
      printStatement.append("Data for " &lt;&lt; rover.getName());
      printStatement.append("\nX: " &lt;&lt; Rover::xcoord);
      printStatement.append("\nY: " &lt;&lt; Rover::ycoord);
      printStatement.append("\nDirection: " &lt;&lt; Rover::direction);
      printStatement.append("\nSpeed: " &lt;&lt; Rover::speed);
      return printStatement;
  
  }
  </code></pre>
  
  <p>Rover.h:</p>
  
  <pre><code>/* 
   * File:   Rover.h
   * Author: Matthew
   *
   * Created on May 14, 2012, 8:10 PM
   */
  
  
  #ifndef ROVER_H
  #define ROVER_H
  
  using namespace std;
  
  
  class Rover
  {
          private:
              string name;
              int xcoord;
              int ycoord;
              string direction;
              int speed;
  
  
      public:
              void setDefaultValues();
              void constructRover();
              //XCoordinates
              void setXcoord(int xcoord);
              int getXcoord();
              //YCoordinates
              void setYcoord(int ycoord);
              int getYcoord();
              //Name
              void setName(string name);
              string getName();
              //Direction
              void setDirection(string direction);
              string getDirection();
              //Speed
              void setSpeed(int speed);
              int getSpeed();
              //Printout
              string getRoverData(Rover rover);
  
  };
  
  #endif  /* ROVER_H */
  </code></pre>
  
  <p>The error I'm currently getting is: </p>
  
  <pre><code>rover.cpp:64: error: no match for 'operator&lt;&lt;' in '"Data for " &lt;&lt; Rover::getName()()'
  </code></pre>
  
  <p><em>The heck does that mean?</em></p>
  
  <p>At this point, what I want the printout to say is:</p>
  
  <pre><code>Data for Default
  X: 0
  Y: 0
  Direction: N
  Speed: 0
  </code></pre>
  
  <p>Any thoughts?</p>
  
  <p>Sorry if the code looks awful as I posted it...haven't done this before.</p>
  
  <hr>
  
  <p><strong>UPDATE:</strong></p>
  
  <hr>
  
  <pre><code>#include &lt;iostream&gt;
  #include "Rover.h"
  using namespace std;
  
  //put functions in here
  
  void Rover::setDefaultValues() {
      name = "Default";
      xcoord = 0;
      ycoord = 0;
      direction = "N";
      speed = 0;
  
  }
  
  void Rover::constructRover() {
  
  }
  
  void Rover::setXcoord(int xcoord) {
      this-&gt;xcoord = xcoord;
  }
  
  void Rover::setYcoord(int ycoord) {
      this-&gt;ycoord = ycoord;
  
  }
  
  void Rover::setName(string name) {
      this-&gt;name = name;
  }
  
  void Rover::setDirection(string direction) {
      this-&gt;direction = direction;
  }
  
  void Rover::setSpeed(int speed) {
      this-&gt;speed = speed;
  }
  
  int Rover::getXcoord() {
      return xcoord;
  
  }
  
  int Rover::getYcoord() {
      return ycoord;
  }
  
  string Rover::getName() {
      return name;
  }
  
  string Rover::getDirection() {
      return direction;
  }
  
  int Rover::getSpeed() {
      return speed;
  }
  
  string Rover::getRoverData(Rover rover) {
      string printStatement = "";
      printStatement.append("Data for " + rover.getName());
      printStatement.append("\nX: " + rover.getXcoord());
      printStatement.append("\nY: " + rover.getYcoord());
      printStatement.append("\nDirection: " + rover.getDirection());
      printStatement.append("\nSpeed: " + rover.getSpeed());
      return printStatement;
  
  }
  </code></pre>
  
  <p>So, now the printout is:</p>
  
  <pre><code>Data for Default
  X:
  Y:
  Direction: N
  Speed:
  </code></pre>
  
  <p>So, it basically just won't print out the zeroes. Thoughts?</p>