Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

STL complex class and iostream

Posted on 1999-01-19
5
Medium Priority
?
900 Views
Last Modified: 2013-11-20
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.
0
Comment
Question by:mclayton99
  • 3
5 Comments
 

Author Comment

by:mclayton99
ID: 1327931
Edited text of question
0
 

Expert Comment

by:koskia
ID: 1327932
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
0
 

Author Comment

by:mclayton99
ID: 1327933
Edited text of question
0
 

Author Comment

by:mclayton99
ID: 1327934
Edited text of question
0
 
LVL 23

Accepted Solution

by:
chensu earned 80 total points
ID: 1327935
It should be OK. Install the Service Pack 3 of Visual C++ 5.0.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question