Skip to main content
Code Review

Return to Answer

replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link
  • Your operator overloads (operator== and operator()) should be const since they don't modify any data members.

  • operator<< can just be a single line. It could also use "\n" instead of std::endl so that one isn't forced to have a buffer flush when invoking it (there is a different between the two there is a different between the two).

     return o << "(" << p.x << ", " << p.y << ", " << p.z << ")\n";
    
  • This can be shortened:

    if (points.size() == 0) {
     vector<Point> empty;
     return empty;
    }
    

    by using empty() and by returning an anonymous vector instead:

     if (points.empty()) {
     return vector<Point>();
     }
    
  • Your operator overloads (operator== and operator()) should be const since they don't modify any data members.

  • operator<< can just be a single line. It could also use "\n" instead of std::endl so that one isn't forced to have a buffer flush when invoking it (there is a different between the two).

     return o << "(" << p.x << ", " << p.y << ", " << p.z << ")\n";
    
  • This can be shortened:

    if (points.size() == 0) {
     vector<Point> empty;
     return empty;
    }
    

    by using empty() and by returning an anonymous vector instead:

     if (points.empty()) {
     return vector<Point>();
     }
    
  • Your operator overloads (operator== and operator()) should be const since they don't modify any data members.

  • operator<< can just be a single line. It could also use "\n" instead of std::endl so that one isn't forced to have a buffer flush when invoking it (there is a different between the two).

     return o << "(" << p.x << ", " << p.y << ", " << p.z << ")\n";
    
  • This can be shortened:

    if (points.size() == 0) {
     vector<Point> empty;
     return empty;
    }
    

    by using empty() and by returning an anonymous vector instead:

     if (points.empty()) {
     return vector<Point>();
     }
    
added 2 characters in body
Source Link
Jamal
  • 35.2k
  • 13
  • 134
  • 238
  • Your operator overloads (operator== and operator()) should be const since they don't modify any data members.

  • operator<< can just be a single line. It could also use "\n" instead of std::endl so that one isn't forced to have a buffer flush when invoking it (there is a different between the two).

     return o << "(" << p.x << ", " << p.y << ", " << p.z << ")\n";
    
  • This can be shortened:

    if (points.size() == 0) {
     vector<Point> empty;
     return empty;
    }
    

    by using empty() and by returning an anonymous vector instead:

     if (points.empty()) {
     return vector<Point>;vector<Point>();
     }
    
  • Your operator overloads (operator== and operator()) should be const since they don't modify any data members.

  • operator<< can just be a single line. It could also use "\n" instead of std::endl so that one isn't forced to have a buffer flush when invoking it (there is a different between the two).

     return o << "(" << p.x << ", " << p.y << ", " << p.z << ")\n";
    
  • This can be shortened:

    if (points.size() == 0) {
     vector<Point> empty;
     return empty;
    }
    

    by using empty() and by returning an anonymous vector instead:

     if (points.empty()) {
     return vector<Point>;
     }
    
  • Your operator overloads (operator== and operator()) should be const since they don't modify any data members.

  • operator<< can just be a single line. It could also use "\n" instead of std::endl so that one isn't forced to have a buffer flush when invoking it (there is a different between the two).

     return o << "(" << p.x << ", " << p.y << ", " << p.z << ")\n";
    
  • This can be shortened:

    if (points.size() == 0) {
     vector<Point> empty;
     return empty;
    }
    

    by using empty() and by returning an anonymous vector instead:

     if (points.empty()) {
     return vector<Point>();
     }
    
Source Link
Jamal
  • 35.2k
  • 13
  • 134
  • 238
  • Your operator overloads (operator== and operator()) should be const since they don't modify any data members.

  • operator<< can just be a single line. It could also use "\n" instead of std::endl so that one isn't forced to have a buffer flush when invoking it (there is a different between the two).

     return o << "(" << p.x << ", " << p.y << ", " << p.z << ")\n";
    
  • This can be shortened:

    if (points.size() == 0) {
     vector<Point> empty;
     return empty;
    }
    

    by using empty() and by returning an anonymous vector instead:

     if (points.empty()) {
     return vector<Point>;
     }
    
lang-cpp

AltStyle によって変換されたページ (->オリジナル) /