delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/01/24/21:47:56

From: <bsptree AT yahoo DOT com> (Andrew Laing)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Newbie questions
Date: Wed, 21 Jan 1998 02:32:00 GMT
Message-ID: <34c55dec.5740948@news.demon.co.uk>
References: <6a391k$896$1 AT talia DOT mad DOT ibernet DOT es>
NNTP-Posting-Host: goajl.demon.co.uk
Lines: 48
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

On Tue, 20 Jan 1998 23:40:45 +0100, "Inyaki Rodríguez"
<0115561c01 AT abonados DOT cplus DOT es> wrote:

>Hi, I'm a newbie with C++ and I want to work with class Complex but I have
>some questions.
>I had write this sample program:
>
>#include <iostream.h>
>#include <complex.h>
>int main(void)
>{
>  Complex z1;
>  Complex z2;
>  z1=complex(1,1);
>  z2=complex(1.5,3);
>  cout << "z1+z2= " << z1+z2 << "\n";
>  cout << "z1*z2= " << z1*z2 << "\n";
>  cout << "z1/z2= " << z1/z2 << "\n";
>  return 0;
>}

Try rewriting it like this :

#include <iostream.h>
#include <complex.h>

int main(void)
{
	float_complex	z1(1,1);
	float_complex	z2(1.5,3);
	cout << "z1+z2= " << z1+z2 << "\n";
  	cout << "z1*z2= " << z1*z2 << "\n";
  	cout << "z1/z2= " << z1/z2 << "\n";
  	return 0;
}

It should now compile without any problems.

I recommend having a look at the header files relating to complex
arithmetic in the lang\cxx\std directory if you get stuck again.

Hope this helps!

Regards

Andrew Laing.

	

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019