Link to home
Start Free TrialLog in
Avatar of mclayton99
mclayton99

asked on

STL complex class and iostream

I am having conflicts compiling with the built in complex class and ostream definitions. The errors are all of the type:

: error C2371: 'ostream' : redefinition; different basic types

and
: error C2784: ...

Here is a sample of how the code is set up and results in the same type errors that I am getting ( under a Win32 console application in MS VC++ version 5.0:

#include <complex>
#include <iostream.h>
using namespace std;

void main( void )
{
   complex<double> temp(1.0, -1.0);
   cout << "Test " << temp.real() << '\t' << temp.imag()
        << endl;
}

Thanks for any assistance.
Avatar of mclayton99
mclayton99

ASKER

Edited text of question
hey
you should really show us how you write that.

with the little you wrote, when using a header file and not pointing the .h, you should include "using namespace std;" below:

#include <complex>
#include <iostream>
using namespace std;

or

#include <complex>
using namespace std;

#include <iostream.h>

but not what you wrote
Edited text of question
Edited text of question
ASKER CERTIFIED SOLUTION
Avatar of chensu
chensu
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial