Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Get this (overlaoding the assignment "=" operator...

ShkaboinkaShkaboinka Member Posts: 79
okay, lets say you got an object (an Abstract Data Type using "struct"
or "class"), and you're overloading the operator "=".

object:: &operator=(object temp) // <--- I know I left out some stuff
{
this = temp;
}

isn't that the dumbest thing? I spent an hour trying to figure out
what was wrong with it; the compiler always becomes "evil" whenever
I try to overload an operator.

Comments

  • ShkaboinkaShkaboinka Member Posts: 79
    : okay, lets say you got an object (an Abstract Data Type using "struct"
    : or "class"), and you're overloading the operator "=".
    :
    : object:: &operator=(object temp) // <--- I know I left out some stuff
    : {
    : this = temp;
    : }
    :
    : isn't that the dumbest thing? I spent an hour trying to figure out
    : what was wrong with it; the compiler always becomes "evil" whenever
    : I try to overload an operator.

    ----> If you cant figure it out, it just recursively calls itself
    ----> in an endless loop;

  • Shawn CarterShawn Carter Member Posts: 0

    _____ \ http://forcoder.org \ free video tutorials and ebooks about < MATLAB Visual Basic .NET PHP Delphi Go PL/SQL C# C Ruby Objective-C Java Perl Assembly Python Swift R JavaScript C++ Scratch Visual Basic Clojure Scala SAS Alice Awk Julia Lua ABAP Logo Prolog Erlang Rust VBScript Scheme LabVIEW Bash D COBOL Lisp Transact-SQL Crystal ML Fortran Hack Dart Apex Kotlin F# Ada FoxPro /> _______

Sign In or Register to comment.