Skip to content

Commit dd2d70e

Browse files
committed
more questions on operator overloading
1 parent 99d784d commit dd2d70e

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

book/print.html

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ <h1 class="menu-title">Jang</h1>
324324
</li>
325325
<li>
326326
<p>Create a <code>Regex</code> to extract dates from this string <code>It was on 2019-03-14, almost after a year from 2018-02-11</code> and store in a
327-
Struct with fields of <code>day</code>, <code>month</code> and <code>year</code>.
327+
Struct with fields of <code>day</code>, <code>month</code> and <code>year</code>.<br />
328328
<code>hint:</code> Use <code>Regex</code> crate</p>
329329
</li>
330330
</ul>
@@ -377,9 +377,16 @@ <h1 class="menu-title">Jang</h1>
377377
operator so that when 2 structs subtract it removes the chars of 2nd from 1st one.</p>
378378
</li>
379379
<li>
380-
<p>Create a struct name <code>ComplexNumber</code> that has 2 variables <code>re</code> &amp; <code>im</code> and overload <code>minus</code>
380+
<p>Create a struct named <code>ComplexNumber</code> that has 2 variables <code>re</code> &amp; <code>im</code> and overload <code>minus</code>
381381
and <code>plus</code> operator to add and subtract complex number.</p>
382382
</li>
383+
<li>
384+
<p>Overload the <code>!</code> operator to conjugate the complex number and <code>==</code> and <code>!=</code> for comparison.</p>
385+
</li>
386+
<li>
387+
<p>Create a struct named <code>Class</code> that contains the class size, section and grade. Overload
388+
the <code>&gt;</code>, <code>&lt;</code>, <code>&gt;=</code>, <code>&lt;=</code>, <code>==</code> operators to compare class sizes of various Classes.</p>
389+
</li>
383390
</ul>
384391
<ul>
385392
<li>Implement a macro named <code>addition</code> to add any amount of numbers. <code>Eg</code>: <code>addition!(5, 6, 57 ,56, 1)</code>

src/chapter_4-enum&patterns/questions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,5 @@ Based on user input change the value of extra (may cause change in recoil time a
2424
* Create a Binary tree and have a method `add` on it to add elements to it and `min` and `max` to find the minimum and maximum element in it.
2525

2626
* Create a `Regex` to extract dates from this string `It was on 2019-03-14, almost after a year from 2018-02-11` and store in a
27-
Struct with fields of `day`, `month` and `year`.
27+
Struct with fields of `day`, `month` and `year`.\
2828
`hint:` Use `Regex` crate
Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
* Create a struct name `Set` that contains a `Vector` of chars and overload the `minus`
22
operator so that when 2 structs subtract it removes the chars of 2nd from 1st one.
33

4-
* Create a struct name `ComplexNumber` that has 2 variables `re` & `im` and overload `minus`
5-
and `plus` operator to add and subtract complex number.
4+
* Create a struct named `ComplexNumber` that has 2 variables `re` & `im` and overload `minus`
5+
and `plus` operator to add and subtract complex number.
6+
7+
* Overload the `!` operator to conjugate the complex number and `==` and `!=` for comparison.
8+
9+
* Create a struct named `Class` that contains the class size, section and grade. Overload
10+
the `>`, `<`, `>=`, `<=`, `==` operators to compare class sizes of various Classes.

0 commit comments

Comments
 (0)