?
Solved

C++ compiling error:C2872 ambiguous symbol

Posted on 2003-12-11
9
Medium Priority
?
1,057 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 500 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

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

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.
Suggested Courses

777 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