Solved

STL complex class and iostream

Posted on 1999-01-19
5
882 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 20 total points
ID: 1327935
It should be OK. Install the Service Pack 3 of Visual C++ 5.0.
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Detect CR LF to each line 12 159
Thin secure Windows 10 5 94
Not needed 13 110
Problem to App source 6 36
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

776 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