Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

basic C++ question

  • 04-09-2008 09:14PM
    #1
    Closed Accounts Posts: 12


    can * operator can be overloaded to perform division?


Comments

  • Registered Users, Registered Users 2 Posts: 654 ✭✭✭Wcool


    why don;t you write a small program to test your questions?
    or are you following a written course in English???


  • Registered Users, Registered Users 2 Posts: 2,379 ✭✭✭toiletduck


    can * operator can be overloaded to perform division?

    Yes.


    :pac:


  • Closed Accounts Posts: 5 unpure


    * operator is loaded to perform division by default, just include <cstdio>, <cstdlib> and <iostream>.
    Or do you mean used externally in runtime?
    (in which case yes)


  • Moderators, Science, Health & Environment Moderators Posts: 10,093 Mod ✭✭✭✭marco_polo


    For me the fact that anyone can, or would want to, change the meaning of the universal symbol of multipication (*) to be a division operator using operator overloading sums up everything that is wrong with the concept IMO. Nice idea but far too often misused in reality.


  • Registered Users, Registered Users 2 Posts: 2,379 ✭✭✭toiletduck


    Personally I find it operator overloading invaluable. What's puzzling me is why the OP didn't try it out first before asking here....


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 2,494 ✭✭✭kayos


    toiletduck wrote: »
    Personally I find it operator overloading invaluable. What's puzzling me is why the OP didn't try it out first before asking here....

    Its called getting others to do his homework for him.


  • Registered Users, Registered Users 2 Posts: 2,379 ✭✭✭toiletduck


    Man I wish I had homework as easy as that back in the day :pac:


  • Moderators, Science, Health & Environment Moderators Posts: 10,093 Mod ✭✭✭✭marco_polo


    toiletduck wrote: »
    Personally I find it operator overloading invaluable. What's puzzling me is why the OP didn't try it out first before asking here....

    Don't get me wrong used appropriatly it is a powerful and tool in a developers arsenal but quite regularly I have see it misused. Can you honestly say would you like to be the guy maintaining a codebase where a divided by b is written as a * b? No thanks :)


  • Closed Accounts Posts: 5 unpure


    * operator is loaded to perform division by default, just include <cstdio>, <cstdlib> and <iostream>.
    Or do you mean used externally in runtime?
    (in which case yes)

    EDIT: * is multiplication.
    My misread.


  • Registered Users, Registered Users 2 Posts: 2,534 ✭✭✭FruitLover


    You can drive a car with your feet if you like. Doesn't make it a good idea.


  • Advertisement
Advertisement