Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <math.h>
- using namespace std;
- class Tcomplex
- {
- private:
- float Re;
- float Im;
- public:
- Tcomplex()
- {
- Re=0;
- Im=0;
- }
- Tcomplex(float Re)
- {
- this->Re=Re;
- Im=0;
- }
- Tcomplex(float Re,float Im)
- {
- this->Re=Re;
- this->Im=Im;
- }
- Tcomplex show()
- {
- cout<<noshowpos<<Re<<showpos<<Im<<"j"<<endl;
- }
- Tcomplex suma(Tcomplex B)
- {
- Tcomplex C;
- C.Re= Re+B.Re;
- C.Im= Im+B.Im;
- return C;
- }
- };
- int main()
- {
- Tcomplex A(2,4);
- Tcomplex B(6,-8);
- A.suma(B).show();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement