Skip to main content
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link
  • Both std::istream and std::ostream are actually not defined in <iostream>, despite the fact that they look similar. They're respectively defined in <istream> and <ostream>.

    You should instead include these in the implementation file and include <iosfwd><iosfwd> (the iostream declaration forwarding library) in the header.

  • These data members should be private:

    glm::vec3 position;
    glm::vec3 normal;
    glm::vec2 texCoord;
    

    Otherwise, they will be accessible outside of the class. If they are not meant to be this way, then you should use a struct instead, which are public by default.

  • If you don't need a default constructor, then leave it out. The compiler will provide one for you.

  • Regarding operator==:

    Conditional operators overloads, such as operator==, should be const as they should not modify any data members:

      bool operator==(const Vertex& other) const;
    

    Its definition could also be split into multiple lines, which is easier to read than one long line:

      bool Vertex::operator==(const Vertex& other) {
          return position == other.position
              && normal == other.normal
              && texCoord == other.texCoord;
      }
    
  • Both std::istream and std::ostream are actually not defined in <iostream>, despite the fact that they look similar. They're respectively defined in <istream> and <ostream>.

    You should instead include these in the implementation file and include <iosfwd> (the iostream declaration forwarding library) in the header.

  • These data members should be private:

    glm::vec3 position;
    glm::vec3 normal;
    glm::vec2 texCoord;
    

    Otherwise, they will be accessible outside of the class. If they are not meant to be this way, then you should use a struct instead, which are public by default.

  • If you don't need a default constructor, then leave it out. The compiler will provide one for you.

  • Regarding operator==:

    Conditional operators overloads, such as operator==, should be const as they should not modify any data members:

      bool operator==(const Vertex& other) const;
    

    Its definition could also be split into multiple lines, which is easier to read than one long line:

      bool Vertex::operator==(const Vertex& other) {
          return position == other.position
              && normal == other.normal
              && texCoord == other.texCoord;
      }
    
  • Both std::istream and std::ostream are actually not defined in <iostream>, despite the fact that they look similar. They're respectively defined in <istream> and <ostream>.

    You should instead include these in the implementation file and include <iosfwd> (the iostream declaration forwarding library) in the header.

  • These data members should be private:

    glm::vec3 position;
    glm::vec3 normal;
    glm::vec2 texCoord;
    

    Otherwise, they will be accessible outside of the class. If they are not meant to be this way, then you should use a struct instead, which are public by default.

  • If you don't need a default constructor, then leave it out. The compiler will provide one for you.

  • Regarding operator==:

    Conditional operators overloads, such as operator==, should be const as they should not modify any data members:

      bool operator==(const Vertex& other) const;
    

    Its definition could also be split into multiple lines, which is easier to read than one long line:

      bool Vertex::operator==(const Vertex& other) {
          return position == other.position
              && normal == other.normal
              && texCoord == other.texCoord;
      }
    
added 958 characters in body
Source Link
Jamal
  • 35.2k
  • 13
  • 134
  • 238

Somewhat minor point regarding I/O:

Neither std::istream nor std::ostream are actually defined in <iostream>; they're respectively defined in <istream> and <ostream>. You can, instead, include these in the implementation file and include <iosfwd> (iostream forwarding library) in the header.

  • Both std::istream and std::ostream are actually not defined in <iostream>, despite the fact that they look similar. They're respectively defined in <istream> and <ostream>.

    You should instead include these in the implementation file and include <iosfwd> (the iostream declaration forwarding library) in the header.

  • These data members should be private:

    glm::vec3 position;
    glm::vec3 normal;
    glm::vec2 texCoord;
    

    Otherwise, they will be accessible outside of the class. If they are not meant to be this way, then you should use a struct instead, which are public by default.

  • If you don't need a default constructor, then leave it out. The compiler will provide one for you.

  • Regarding operator==:

    Conditional operators overloads, such as operator==, should be const as they should not modify any data members:

      bool operator==(const Vertex& other) const;
    

    Its definition could also be split into multiple lines, which is easier to read than one long line:

      bool Vertex::operator==(const Vertex& other) {
          return position == other.position
              && normal == other.normal
              && texCoord == other.texCoord;
      }
    

Somewhat minor point regarding I/O:

Neither std::istream nor std::ostream are actually defined in <iostream>; they're respectively defined in <istream> and <ostream>. You can, instead, include these in the implementation file and include <iosfwd> (iostream forwarding library) in the header.

  • Both std::istream and std::ostream are actually not defined in <iostream>, despite the fact that they look similar. They're respectively defined in <istream> and <ostream>.

    You should instead include these in the implementation file and include <iosfwd> (the iostream declaration forwarding library) in the header.

  • These data members should be private:

    glm::vec3 position;
    glm::vec3 normal;
    glm::vec2 texCoord;
    

    Otherwise, they will be accessible outside of the class. If they are not meant to be this way, then you should use a struct instead, which are public by default.

  • If you don't need a default constructor, then leave it out. The compiler will provide one for you.

  • Regarding operator==:

    Conditional operators overloads, such as operator==, should be const as they should not modify any data members:

      bool operator==(const Vertex& other) const;
    

    Its definition could also be split into multiple lines, which is easier to read than one long line:

      bool Vertex::operator==(const Vertex& other) {
          return position == other.position
              && normal == other.normal
              && texCoord == other.texCoord;
      }
    
Source Link
Jamal
  • 35.2k
  • 13
  • 134
  • 238

Somewhat minor point regarding I/O:

Neither std::istream nor std::ostream are actually defined in <iostream>; they're respectively defined in <istream> and <ostream>. You can, instead, include these in the implementation file and include <iosfwd> (iostream forwarding library) in the header.