• Saves Valuable Time
  • Trusted Accuracy since 2004
  • 15-Day Money-Back Guarantee

C++ Equivalent to C# Operator Overloading

C# operator overloading is similar to C++ operator overloading, except that C# operator overloads are static methods while C++ operator overloads are instance methods. During conversion by C# to C++ Converter, the first parameter is removed and corresponds to 'this'.

C# C++
public class SomeType
    private int IntValue;

    public static int operator +(SomeType X, SomeType Y)
        return X.IntValue + Y.IntValue;
class SomeType
    int IntValue = 0;

    int operator + (const SomeType &Y)
        return this->IntValue + Y.IntValue;

Use C# to C++ Converter to convert from C# to C++.     

Additional resource: C++ and C# Equivalents

Copyright © 2004 – 2021 Tangible Software Solutions, Inc.