C++ Operator Classes: Real & Imaginary Numbers Explained

In summary, Complex numbers are a type of data that can be easily represented in programming. They are important for solving roots of polynomials, transcendental functions, and many other mathematical problems.
  • #1
asma_MIT
6
0
i don't clearly understand that what are the real and imaginary numbers in c++ classes when defining operators. help me .
thnx
 
Last edited by a moderator:
Technology news on Phys.org
  • #3
<< aggressive response deleted by berkeman >>
 
Last edited by a moderator:
  • #4
Yes, this is a math question. Real and imaginary numbers are not part of C++, classes and operators are.
 
  • #5
its true its math problem but in programming it is related now i want to know what are the real n imaginary numbers.
if i say c=a+d
then a is real n d is imaginary number what does it mean...
thnx if u will tell
 
  • #6
The new c++ TR1 standard and the proposed C++0x have complex number classes, you should check if your compiler supports them.

edit: in your example c would be a complex number, it's normally written c = a +id
 
  • #7
I have posted link to an explanation.
 
  • #8
what a lovely answer it is...
but its true that its not helpful for me.
thnx 4 ur reply..
i take my question back no can answer.....
 
  • #9
As mgb_phys posted a complex number is a number of the form c = a + id. As the link that Borek posted indicates in the a+di form a and d are real numbers and i is the imaginary number (the square root of -1). Here a is called the real part of c and d is called the imaginary part of c.

Complex numbers are important for many mathematical functions such as solving roots of polynomials, transcendental functions, etc. They can be easily represented programmatically as a named pair of floating point numbers representing the real part and the imaginary part, so they form a kind of prototypical example of a structured data type.

Your reply to Borek was not very polite. He correctly identified your question and pointed you to a good site to fully answer it. He did not deserve to be replied to in that fashion.
 
  • #10
soorrry Borek
now i understand the answer thnx actually i was in tention so sorry 4 that attitude
 

Related to C++ Operator Classes: Real & Imaginary Numbers Explained

1. What are operator classes in C++?

Operator classes in C++ are used to define how operators, such as addition and subtraction, behave for specific data types. They allow for custom behavior and functionality of operators for user-defined types, such as real and imaginary numbers.

2. How are operator classes used for real and imaginary numbers in C++?

Operator classes for real and imaginary numbers in C++ define how arithmetic operations, such as addition and multiplication, are performed on these types. They also allow for comparison operations, such as equality and inequality checks, to be performed on these numbers.

3. Can operator classes be used for other data types besides real and imaginary numbers?

Yes, operator classes can be used for any user-defined data type. They can be defined for any class or struct in C++ to customize the behavior of operators for that type.

4. What is the benefit of using operator classes for real and imaginary numbers in C++?

Using operator classes for real and imaginary numbers allows for more natural and intuitive operations on these types. It also allows for code to be more readable and maintainable, as the behavior of operators is defined within the class itself rather than scattered throughout the code.

5. How are operator classes for real and imaginary numbers defined in C++?

To define operator classes for real and imaginary numbers in C++, you would use the operator keyword followed by the desired operator, such as + for addition. Within the class definition, you would then define the behavior and functionality of that operator for the given data type.

Similar threads

  • Programming and Computer Science
Replies
22
Views
1K
  • Programming and Computer Science
Replies
2
Views
1K
  • Programming and Computer Science
Replies
23
Views
2K
  • Programming and Computer Science
Replies
5
Views
2K
  • Programming and Computer Science
Replies
4
Views
857
  • Programming and Computer Science
Replies
8
Views
1K
  • Programming and Computer Science
Replies
34
Views
2K
  • Programming and Computer Science
Replies
8
Views
1K
  • Programming and Computer Science
Replies
31
Views
2K
  • Programming and Computer Science
Replies
8
Views
3K
Back
Top