Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

'std' is not a class or namespace name

Status
Not open for further replies.

ruud79

Programmer
Jul 30, 2003
7
US
Hi,

I have just started programming using microsoft Visual C++ 6.0.

I want to use Vector and String in my code and so I included <vector> and <string>, but I get the error message &quot; 'std' : is not a class or namespace name &quot;.

The code looks like this:

include# <string>
include# <vector>

void CDataAnalyserView::OnFileLoad()
{
CFileDialog dlg(true);
dlg.DoModal();
if (dlg.GetFileTitle() != &quot;&quot;)
{
std::string filename = dlg.GetPathName();
}
}

I've read there is a bug in Visual C++ 6.0 that the namespace has not been defined and to work around the problem <cstdlib> should be included in namespace std like this:
namespace std
{
include# <cstdlib>
};

Maybe this is a stupid question but where do I put this code?


 
change
include# <string>
include# <vector>
to
#include <string>
#include <vector>
and
include# <cstdlib>
to
#include <cstdlib>


Ion Filipski
1c.bmp

ICQ: 95034075
AIM: IonFilipski
filipski@excite.com
 
Sorry, this was a typing mistake in this thread. In the code I have put it down correctly.
 
>Sorry, this was a typing mistake in this thread. In the code I have put it down correctly.

Are you sure? The above mentioned includes should indeed solve your problem. It works for me at least...

/Per

if (typos) cout << &quot;My fingers are faster than my brain. Sorry for the typos.&quot;;
 
I'm sure.

I included these header files like this now:

#include <vector>
#include <string>
#include <cstdlib>

The line where it gets the error is:

std::string filename = dlg.GetPathName();

The error message:

'std' : is not a class or namespace name
 
are you using VisualC++ or BorlandC++?

Ion Filipski
1c.bmp

ICQ: 95034075
AIM: IonFilipski
filipski@excite.com
 
which version?

Ion Filipski
1c.bmp

ICQ: 95034075
AIM: IonFilipski
filipski@excite.com
 
is std::string filename = dlg.GetPathName(); a single place where you use name std?

Ion Filipski
1c.bmp

ICQ: 95034075
AIM: IonFilipski
filipski@excite.com
 
ok, I think I have got your trouble.
Try to change
#include <vector>
#include <string>
#include <cstdlib>
to
#include <vector>
#include <string>
namespace std
{
#include <cstdlib>
};


Ion Filipski
1c.bmp

ICQ: 95034075
AIM: IonFilipski
filipski@excite.com
 
Thanks.

I tried this, but now I get a different error message:

'string' : is not a member of 'std'

 
try this:
namespace std
{
#include <cstdlib>
};
#undef _STRING_
#include <vector>
#include <string>


Ion Filipski
1c.bmp

ICQ: 95034075
AIM: IonFilipski
filipski@excite.com
 
this one also could solve:
namespace std
{
#include <cstdlib>
};
#if !defined(__cplusplus)
#defined __cplusplus
#endif
#include <vector>
#include <string>


Ion Filipski
1c.bmp

ICQ: 95034075
AIM: IonFilipski
filipski@excite.com
 
by the way, take a look into headers, if you are attentive, #include<string> also winn include #include<cstrlib>

Ion Filipski
1c.bmp

ICQ: 95034075
AIM: IonFilipski
filipski@excite.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top