Есть код
#include<conio.h>
#include<math.h>
#include<iostream.h>
class Complex
{
private:
int A, B;
public:
Complex(int, int);
Complex() {};
int GetA();
int GetB();
void PutA(int);
void PutB(int);
void PrintComplex();
void MultComplex(Complex, Complex&); // 1
void pMultComplexV(Complex, Complex*); // 2
Complex* pMultComplex(Complex); // 3
void MltComplexP(Complex*, Complex&); // 7
void pMltComplexP(Complex*, Complex*); // 8
Complex* pMltComplex(Complex*); // 9
Complex MultComplex(Complex); // 12
Complex operator*(Complex); // 13
friend void MultComplex(Complex, Complex, Complex&); // 14
friend void MultComplex2(Complex, Complex, Complex*); // 15
};
void MultV(Complex, Complex, Complex&); // 4
Complex* pMultVct(Complex, Complex); // 5
void MultVec(Complex, Complex, Complex*); // 6
void MltVct(Complex*, Complex*, Complex&); // 10
Complex* pMltVct(Complex*, Complex*); // 11
Complex::Complex(int A, int B): A(A), B(B) {}
int Complex::GetA() {return A;}
int Complex::GetB() {return B;}
void Complex::PutA(int A) {this->A=A;}
void Complex::PutB(int B) {this->B=B;}
void Complex::PrintComplex() {cout<<"A = "<<A<<" B = "<<B<<endl;};
void Complex::MultComplex(Complex Z2, Complex& CR) // 1
{
CR.A = A*Z2.A - B*Z2.B;
CR.B = A*Z2.B + B*Z2.A;
}
void Complex::pMultComplexV(Complex Z2, Complex* pC) // 2
{
pC->A = A*Z2.A - B*Z2.B;
pC->B = A*Z2.B + B*Z2.A;
}
Complex* Complex::pMultComplex(Complex Z2) // 3
{
Complex* pC;
pC->A = A*Z2.A - B*Z2.B;
pC->B = A*Z2.B + B*Z2.A;
return pC;
}
void MultV(Complex Z1, Complex Z2, Complex &C) // 4
{
C.PutA( Z1.GetA() * Z2.GetA() - Z1.GetB() * Z2.GetB() );
C.PutB( Z1.GetA() * Z2.GetB() + Z1.GetB() * Z2.GetA() ); // 1 2 2 1
}
Complex* pMultVct(Complex Z1, Complex Z2) // 5
{
Complex *pC;
pC->PutA( Z1.GetA() * Z2.GetA() - Z1.GetB() * Z2.GetB());
pC->PutB( Z1.GetA() * Z2.GetB() + Z1.GetB() * Z2.GetA());
return pC;
}
void MultVec(Complex Z1, Complex Z2, Complex *pC) // 6
{
pC->PutA( Z1.GetA() * Z2.GetA() - Z1.GetB() * Z2.GetB());
pC->PutB( Z1.GetA() * Z2.GetB() + Z1.GetB() * Z2.GetA());
}
void Complex::MltComplexP(Complex* pZ2, Complex &C) // 7
{
C.PutA( A * pZ2->GetA() - B * pZ2->GetB());
C.PutB( A * pZ2->GetB() + B * pZ2->GetA());
}
void Complex::pMltComplexP(Complex* pZ2, Complex* pC) // 8
{
pC->PutA( A * pZ2->GetA() - B * pZ2->GetB());
pC->PutB( A * pZ2->GetB() + B * pZ2->GetA());
}
Complex* Complex::pMltComplex(Complex* pZ2) // 9
{
Complex* pR;
pR->PutA( A * pZ2->GetA() - B * pZ2->GetB());
pR->PutB( A * pZ2->GetB() + B * pZ2->GetA());
return pR;
}
void MltVct(Complex* pZ1, Complex* pZ2, Complex& CR) // 10
{
CR.PutA( pZ1->GetA() * pZ2->GetA() - pZ2->GetB() * pZ2->GetB());
CR.PutB( pZ1->GetA() * pZ2->GetB() + pZ2->GetB() * pZ2->GetA());
}
Complex* pMltVct(Complex* pZ1, Complex* pZ2) // 11
{
Complex* pV;
pV->PutA( pZ1->GetA() * pZ2->GetA() - pZ2->GetB() * pZ2->GetB());
pV->PutB( pZ1->GetA() * pZ2->GetB() + pZ2->GetB() * pZ2->GetA());
return pV;
}
Complex Complex::MultComplex(Complex Z2) // 12
{
Complex R;
R.A = A * Z2.A - B * Z2.B;
R.B = A * Z2.B + B * Z2.A;
return R;
}
Complex Complex::operator* (Complex Z2) // 13
{
Complex R;
R.A = A * Z2.A - B * Z2.B;
R.B = A * Z2.B + B * Z2.A;
return R;
}
void MultComplex(Complex Z1, Complex Z2, Complex &C) // 14
{
C.A = Z1.A * Z2.A - Z1.B * Z2.B;
C.B = Z1.A * Z2.B + Z1.B * Z2.A;
}
void MultComplex2(Complex Z1, Complex Z2, Complex *pC) // 15
{
pC->A = Z1.A * Z2.A - Z1.B * Z2.B;
pC->B = Z1.A * Z2.B + Z1.B * Z2.A;
}
void main()
{
clrscr();
Complex
Z1(1,2), Z2(1,2),
C1, C4, C7, C8, C10, C12, C13, C14, C15,
*pC2, *pC3, *pC5, *pC6, *pC8, *pC9, *pC11;
cout<<"Z1: "; Z1. PrintComplex(); getch();
cout<<"Z2: "; Z2. PrintComplex(); getch();
// Z1.MultComplex(Z2, C1); // 1
// cout<<"C1: ";
// C1.PrintComplex(); getch();
// Z1.pMultComplexV(Z2, pC2); // 2
// cout<<"C2: ";
// pC2->PrintComplex(); getch();
pC3 = Z1.pMultComplex(Z2); // 3
cout<<"C3: ";
pC3->PrintComplex(); getch();
// MultV(Z1, Z2, C4); // 4
// cout<<"C4: ";
// C4.PrintComplex(); getch();
// pC5 = pMultVct(Z1, Z2); // 5
// cout<<"C5: ";
// pC5->PrintComplex(); getch();
// MultVec(Z1, Z2, pC6); // 6
// cout<<"C6: ";
// pC6->PrintComplex(); getch();
// Z1.MltComplexP(&Z2, C7); // 7
// cout<<"C7: ";
// C7.PrintComplex(); getch();
// Z1.pMltComplexP(&Z2, pC8); // 8
// cout<<"C8: ";
// pC8->PrintComplex(); getch();
// Z1.pMltComplexP(&Z2, &C8); // 8
// cout<<"C8: ";
// C8.PrintComplex(); getch();
// pC9 = Z1.pMltComplex(&Z2); // 9
// cout<<"C9: ";
// pC9->PrintComplex(); getch();
// MltVct(&Z1, &Z2, C10); // 10
// cout<<"C10: ";
// C10.PrintComplex(); getch();
// pC11 = pMltVct(&Z1, &Z2); // 11
// cout<<"C11: ";
// pC11->PrintComplex(); getch();
// C12 = Z1.MultComplex(Z2); // 12
// cout<<"C12: ";
// C12.PrintComplex(); getch();
// cout<<"C12: ";
// Z1.MultComplex(Z2).PrintComplex();
// getch();
// C13 = Z1*Z2; // 13
// cout<<"C13: ";
// C13.PrintComplex(); getch();
// MultComplex(Z1, Z2, C14); // 14
// cout<<"C14: ";
// C14.PrintComplex(); getch();
// MultComplex2(Z1, Z2, &C15); // 15
// cout<<"C15: ";
// C15.PrintComplex(); getch();
}
Выяснил, что виснет на функции pMultComplex, я не понимаю с чем это связано.