Given the following composite data type in a statically-typed language: struct…
TS-SET (TG-SET) 2024
Given the following composite data type in a statically-typed language: struct Complex { double real; double imag; } If you were to extend this type to support addition of two Complex numbers, which operator overloading method would be most appropriate?
- A.
Define a global function for adding two Complex numbers.
- B.
Overload the “ “ operator within the Complex struct definition.
- C.
Use inheritance to create a subclass that supports addition.
- D.
Implement a template function for adding Complex numbers.
Attempted by 6 students.
Sign up free to check your answer
Sign up freeLoading lesson…

