std not recognized
-
Hi All, My application doesnt compile if I use anything from namespace std. I have tried "using namespace std" and std:: Can anyone tell me what the problem could be? Extremely sorry for asking a basic question. I am just a starter. Hope you all understand. :-) Thanks and Regards, Anil
-
Hi All, My application doesnt compile if I use anything from namespace std. I have tried "using namespace std" and std:: Can anyone tell me what the problem could be? Extremely sorry for asking a basic question. I am just a starter. Hope you all understand. :-) Thanks and Regards, Anil
When you say it doesn't compile, what is the error ? Did you #include what you're trying to use ?
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog
-
When you say it doesn't compile, what is the error ? Did you #include what you're trying to use ?
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog
Hi Christian, Now the previous error disappeared. But I still get error C2079: 'Logger::m_oStream' uses undefined class 'std::basic_ofstream<_Elem,_Traits>' with [ _Elem=char, _Traits=std::char_traits ] Can you please help? I am using Visual Studio .Net 2003 Thanks and Regards, Anil
-
Hi Christian, Now the previous error disappeared. But I still get error C2079: 'Logger::m_oStream' uses undefined class 'std::basic_ofstream<_Elem,_Traits>' with [ _Elem=char, _Traits=std::char_traits ] Can you please help? I am using Visual Studio .Net 2003 Thanks and Regards, Anil
If you could post a minimal code snippet that reproduces the error, it'd be easier to figure otu what headers you are missing.
Regards, Nish
Nish’s thoughts on MFC, C++/CLI and .NET (my blog)
Currently working on C++/CLI in Action for Manning Publications. (*Sample chapter available online*) -
Hi Christian, Now the previous error disappeared. But I still get error C2079: 'Logger::m_oStream' uses undefined class 'std::basic_ofstream<_Elem,_Traits>' with [ _Elem=char, _Traits=std::char_traits ] Can you please help? I am using Visual Studio .Net 2003 Thanks and Regards, Anil
Are you including iostream ( not iostream.h ) ?
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog
-
Are you including iostream ( not iostream.h ) ?
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog
-
No - you need to post your code for us to be able to help more.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog
-
No - you need to post your code for us to be able to help more.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog
my .h file #pragma once using namespace std; class Logger { public: Logger(void); ~Logger(void); private: char *m_pFileName; std::ofstream m_oStream; public: void LogMsg(char * functionName, char * condition); }; cpp file #include "StdAfx.h" #include #include ".\logger.h" Logger::Logger(void) : m_pFileName(NULL) { m_pFileName = "E:\\projects\\something.log"; m_oStream.open(m_pFileName, std::ios_base::app); } Logger::~Logger(void) { } void Logger::LogMsg(char * functionName, char * condition) { } Thanks in Advance for any help....[:)]
-
my .h file #pragma once using namespace std; class Logger { public: Logger(void); ~Logger(void); private: char *m_pFileName; std::ofstream m_oStream; public: void LogMsg(char * functionName, char * condition); }; cpp file #include "StdAfx.h" #include #include ".\logger.h" Logger::Logger(void) : m_pFileName(NULL) { m_pFileName = "E:\\projects\\something.log"; m_oStream.open(m_pFileName, std::ios_base::app); } Logger::~Logger(void) { } void Logger::LogMsg(char * functionName, char * condition) { } Thanks in Advance for any help....[:)]
Anil_vvs wrote:
std::ofstream m_oStream;
std:: is a waste of time, you've put a using above it. However, if you want a member variable, the #include needs to be in the .h, not the .cpp. Alternatively, you can put it in an anonymous namespace in the cpp.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog
-
Anil_vvs wrote:
std::ofstream m_oStream;
std:: is a waste of time, you've put a using above it. However, if you want a member variable, the #include needs to be in the .h, not the .cpp. Alternatively, you can put it in an anonymous namespace in the cpp.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog