Task 1

Having learnt a massive chunk of C++ now I want you to try and right some code for yourself. Your section is to create a triple struct, ie. like a 3D point but semantically more general. You must demonstrate and run all of the properties of the struct. The program should be called triple.cxx (or triple.main.cxx if using bpt)

Requirements

  • Must have three members of the same type (either int, float or double)
  • A way to add two points
  • A way to subtract two points
  • A way to multiply a point by a scalar (of the same underlying type)
  • A way to divide a point by a scalar (of the same underlying type)
  • A way to be print a formatted output using std::cout

Bonus

  • A way to be created using input from std::cin
  • Create a 'triple' structure for the other underlying types.

Submitting

You can use Godbolt or bpt to build and test your struct. Once you have created your implementation:

  • Clone this repo using git clone https://github.com/MonashDeepNeuron/HPP.git.
  • Create a new branch using git checkout -b triple/<your-name>.
  • Create a folder in the /submissions directory with your name.
  • Create a folder with the name of this task.
  • Copy your mini project into this directory (bpt setup, cmake scripts etc.) with a README.md or comment in the code on how to run the program (verify it still works). There is a sample header file in /templates that you can use.
  • Go to https://github.com/MonashDeepNeuron/HPP/pulls and click 'New pull request'.
  • Change the branches in the drop down so that your branch is going into main and `Create new pull request.
  • Give the pull request a title and briefly describe what you were able to implement and any struggles you had.
  • On the right side-panel, under the 'Assignees' section, click the cog and assign me.
  • Click 'Create pull request' and I'll take it from there.

Note: If you created a GodBolt instance, put the link in a comment at the top of the file (under your copy comments). This is generated by clicking the share button in the top-right-most corner of the webpage and clicking the 'short link' option.