Skip to content

About operators exercise #439

Description

@chavid

I found it too too long. Few suggestions to better focus on operators only:

  • Provide in the original code the normalize() function and std::gcd stuff.
  • Provide int the original code the constructors, public attributes, constructors, assign method, and externals functions such as multiply, add, compare (returning -1,0,1 ?), print.
  • Ask to replace the functions with operators: =, +, *, <=>, <<
  • Then ask to add, reusing previous ones: !=, +=, *=.
  • Show that with <=> implemented, then <, <=, >, >= are automatically infered ?
  • Optionally, make all the assignments returning *this, like in operator<<, and explain this permit chaining.
  • Optionally, make them move the operators as inline friend functions, and make attributes private.
  • Optionnaly, discuss the pros and cons of making the unary constructor explicit.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions