Solved

C++ compiling error:C2872 ambiguous symbol

Posted on 2003-12-11
9
1,003 Views
Last Modified: 2010-04-01
When I'm using :
#include <iostream.h>
#include<fsteam.h>
#include<string>
using namespace std;

I'm getting this error:
error C2872: 'ostream' : ambiguous symbol

How can I solve it???

0
Comment
Question by:reemYaz
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 125 total points
ID: 9925344
>>How can I solve it???

Don't mix STL headers with non-standard headers:

#include <iostream>
#include<fsteam>
#include<string>
using namespace std;


0
 
LVL 9

Expert Comment

by:tinchos
ID: 9925352
Hi reemYaz,

Try replacing the includes with the standard ones (without the .h)

#include <iostream>
#include<fstream>
#include<string>
using namespace std;

Cheers!

Tincho
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 9926132
Also, <fstream> is mis-splelt as <fsteam>. You forgot to put an 'r' there.

Mayank.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 30

Expert Comment

by:Mayank S
ID: 9926140
Oh, Tinchos has put it right. By the way, do you need to include <iostream> if <fstream> is already included?
0
 
LVL 9

Expert Comment

by:tinchos
ID: 9927785
I'm not sure as code was not posted......

I just corrected the posted code........ lets hope that works for reemYaz

Tincho
0
 
LVL 11

Expert Comment

by:cup
ID: 9933603
iostream.h is for the old standard (V2), iostream is for the new standard (V3, STL).  Most systems have iostream.h and fstream.h for backward compatibility, and, as mentioned earlier, you shouldn't mix the two.
0
 

Expert Comment

by:MAYURNATH
ID: 9971266
#include <string> - is using the std namespace

#include <iostream.h> is not in namespace.

namespace concept is to avoid this type of problems.

if u write a function in on library , and another library also contains the same fucntion then u go for specifying a particualr libarary to a namespace.

u want to use <string> ostream then go like std::ostream and declare ur variable
u want to use <iostream.h> ostream then go like ostream and declare ur variable

In the above situation u have to avoid using namespace std;

the sample code is as follows :
#include <iostream.h>
#include <fstream.h>
#include <string>

int main(int argc, char* argv[])
{
      std::ostream    aStringStream ;
      ostream           aIOStream ;
      return 0;
}

i suppose this will clear the picture

thanx
0
 
LVL 9

Expert Comment

by:tinchos
ID: 10356425
No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation for this question in the Cleanup topic area:

Accept: jkr {http:#9925344}

Please leave any comments here within the next four days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Tinchos
EE Cleanup Volunteer
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
typedef std::deque<BYTE> ByteVector is broken in vs2012 23 94
max float value 3 66
object oriented programming comparison 5 92
Winapi.Windows.hpp problem 7 35
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

738 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