>>I mean, who ever heard of a buss pass? WTF is that all about?
Don't come crying to me when unreaped zombies start eating your brains :-)
>>and why on earth would i get such a crazy output?
Because you're not initializing your variables, they have nothing but garbage in them. The following code fixes all but the final call to disS(), the problem with that one is that you never call a function which sets s or n :-)
Code:
#include <iostream>
using namespace std;
class Complex
{
int real;
double imaginary;
int sumreal;
double sumimaginary;
int areal;
int breal;
double aimaginary;
double bimaginary;
int b;
float l;
int s;
float n;
public:
Complex(int , double ,int ,double);
void AddR(int,int);
void SubR(int,int);
void AddI(double,double);
void SubI(double,double);
void displayA();
void disS();
};
Complex::Complex(int r, double i, int re, double im)
{
areal = r;
aimaginary = i;
breal = re;
bimaginary = im;
}
void Complex::AddR(int areal, int breal)
{
b = areal + breal;
}
void Complex::SubR(int areal,int breal)
{
s = areal - breal;
}
void Complex::AddI( double aimaginary, double bimaginary)
{
l = aimaginary + bimaginary;
}
void Complex::SubI( double aimaginary, double bimaginary)
{
n = aimaginary - bimaginary;
}
void Complex ::displayA()
{
cout<<"("<<b<<","<<l<<"i )"<<endl;
}
void Complex ::disS()
{
cout<<"("<<s<<","<<n<<"i )"<<endl;
}
int main()
{
cout<<"This program will add and subtract\n"
"two predefined sets of real and imaginary numbers\n";
cout<<"(12 , 13.4i) + ( 13, 32.4i)\n\n\n";
cout<<"\n";
Complex b(12.3, 13.4, 12.4 ,32.4);
b.AddR(12, 12.4);
b.AddI(13, 32.4);
b.displayA();
cout<<"\n\n\n";
cout<<"(12 , 13.4i) - ( 12 , 32.4i)\n\n\n";
b.AddR(12, 12.4);
b.AddI(13, 32.4);
b.disS();
return 0;
}