Solved

C++ compiling error:C2872 ambiguous symbol

Posted on 2003-12-11
9
956 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
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:mayankeagle
ID: 9926132
Also, <fstream> is mis-splelt as <fsteam>. You forgot to put an 'r' there.

Mayank.
0
 
LVL 30

Expert Comment

by:mayankeagle
ID: 9926140
Oh, Tinchos has put it right. By the way, do you need to include <iostream> if <fstream> is already included?
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…

760 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now