Overload a method or use default values? c++

后端 未结 4 1279
再見小時候
再見小時候 2021-01-04 01:11

I\'m still relatively new to C++ and I can\'t seem to figure out the difference in the following two ways of coding a function that may take one parameter or maybe two or th

4条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-04 01:33

    First off, you're talking about overloading, not overriding. Overriding is done for virtual functions in a derived class. Overloading refers to the same function name with a different signature.

    The difference is logical - in the first case (2 versions), the two functions can behave completely different, whereas the second case will have more or less the same logic. It's really up to you.

提交回复
热议问题