Results 1 to 3 of 3

Thread: overload

Threaded View

  1. #3
    Fanatic Member
    Join Date
    Feb 2006
    Posts
    607

    Re: overload

    First off all.. That is C++.. This is a vb.net forum. We do have a C, C++ forum where you shouldve posted this.

    a friend function is a global function that has access to class members. Therefore the operator will be global. This will overload the + operator for the whole application (well in simplest terms).

    The member function will be inside the public section of the class. This overload will only work if overloading an object. For example overload the + is a unary operation. Therefore in your main() you can have this

    Code:
    myType x, a;
    a = +x
    or the - operator which means
    Code:
    myType x, a;
    a = -x
    however, IT DOES NOT OVERLOAD THIS:
    Code:
    myType x, y, z;
    z = x + y;
    To do that you must overload the binary operator.

    You can guess the third question. (hint it goes in the class but figure out which section)

    I highly recommend reading over your course outline/notes. If this is for an exam then you need to know this stuff really well.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width