String In c++

How to define string in c++.
When I try it it gives errors like given below
1
2
3
4
5
6
7
#include<iostream>
#include<string>
using namespace std;
 int main()
{
string s1;
}


It gives following errors

Multiple markers at this line
- reference to ‘string’ is
ambiguous
- expected ‘;’ before ‘s1’

I used it on eclipse.
Are you sure you get the error when compiling that code? If so what compiler and version are you using?
The error means that there is more than one thing you could be referring to when you write string, which suggests that you are defining string somewhere. You could get rid of the error be qualifying the name std::string instead of string but that isn't really the crux of the issue.
Thanks Lachlan Easton.now its working well.The problem was occurred because class name is also string. Thanks for support.
Topic archived. No new replies allowed.