Home Forums Computational Design Methods About the overload

Viewing 4 reply threads
  • Author
    Posts
    • #16455
      Ruo-Xuan Wu
      Participant

      I have a quetion about the “Function” video, in this section, 20:23.
      Why we need to assign “rot = 0”? But when it only have i and k in the paremetic don’t need to.

      According to error information, why we need to procedure the function twice? What is the meaning of overload?

    • #16482
      Reinhard Koenig
      Keymaster

      Dear Ruo-Xuan Wu,

      the additional parameter “rot=0” gives you the option to send this parameter to your function if you’d like to change it (use something else than 0). But if you don’t like to change it you can just ignore this parameter, since it is set to 0 already. In case you never want to use the rotation parameter rot, you don’t need it, but I showed it for an example of how you can add optional parameters (=parameters that you may use or not).

      Clear?

      Best regards

      Reinhard

    • #16485
      Ruo-Xuan Wu
      Participant

      I can understand we need a “rot” to receive the number from main function.
      But it’s unclear for me that “i” and  “k” both don’t need it, only we create a new parameter “rot” need to be overloaded.

    • #16486
      Reinhard Koenig
      Keymaster

      Usually, you need to send values for parameters that you define for the input of a function (as i and k in our example). That’s the most often used variant. But you can use optional parameters as inputs as well (after the obligatory parameters). When you call the function, you can decide if you change the optional parameters or not. That’s not possible with the “normal” parameters as i and k.

      Maybe other explanations may be helpful:
      https://www.dotnetperls.com/optional-parameters

      I hope this helps you understand the concept of optional parameters.

    • #16487
      Ruo-Xuan Wu
      Participant

      Thank your for your explanaiton, I think dicuss face-to-face tomorrow would be more easily to understand :).

Viewing 4 reply threads
  • You must be logged in to reply to this topic.