Skip to content

About operators exercise #439

Open
Open
@chavid

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions