Skip to content

Commit b4bf723

Browse files
committed
Update cpp-for-cscharp.md
1 parent 0224aa6 commit b4bf723

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

content/posts/cpp-for-cscharp.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -709,12 +709,10 @@ With operator overloading we can make operators work for user defined classes, w
709709
+, -, *, /, =, +=, -=, *=, /=
710710
```
711711

712-
### In C# operator overloading works like this:
712+
**In C# operator overloading works like this:**
713713

714714
In C# you always need to make an operator overload ``public`` and ``static``. And in C# there is no separate “member vs non-member” distinction like in C++, so the object on the left side of the operator becomes the the first argument, and the object on the right side becomes the second argument so in C# ``a + b`` is interpreted as ``T.operator+(a, b)`` in code.
715715

716-
In C# operator overloading example:
717-
718716
```csharp
719717
// csharp
720718
public static T operator+(T a, T b)
@@ -723,7 +721,7 @@ public static T operator+(T a, T b)
723721
}
724722
```
725723

726-
### In C++ operator overloading works like this:
724+
**In C++ operator overloading works like this:**
727725

728726
In a **member** operator overload, the object on the left side of the operator becomes the current object ``this``, and the object on the right side is passed as a parameter. So for example ``a + b`` is roughly interpreted as ``a.operator+(b)`` in code.
729727

0 commit comments

Comments
 (0)