Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Managed C++/CLI
  4. std not recognized

std not recognized

Scheduled Pinned Locked Moved Managed C++/CLI
questionhelp
10 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Anil_vvs
    wrote on last edited by
    #1

    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

    C 1 Reply Last reply
    0
    • A Anil_vvs

      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

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      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

      A 1 Reply Last reply
      0
      • C Christian Graus

        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

        A Offline
        A Offline
        Anil_vvs
        wrote on last edited by
        #3

        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

        N C 2 Replies Last reply
        0
        • A Anil_vvs

          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

          N Offline
          N Offline
          Nish Nishant
          wrote on last edited by
          #4

          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*)

          1 Reply Last reply
          0
          • A Anil_vvs

            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

            C Offline
            C Offline
            Christian Graus
            wrote on last edited by
            #5

            Are you including iostream ( not iostream.h ) ?

            Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog

            A 1 Reply Last reply
            0
            • C Christian Graus

              Are you including iostream ( not iostream.h ) ?

              Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog

              A Offline
              A Offline
              Anil_vvs
              wrote on last edited by
              #6

              right chris.....i am including iostream.....any problem with that...??

              C 1 Reply Last reply
              0
              • A Anil_vvs

                right chris.....i am including iostream.....any problem with that...??

                C Offline
                C Offline
                Christian Graus
                wrote on last edited by
                #7

                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

                A 1 Reply Last reply
                0
                • C Christian Graus

                  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

                  A Offline
                  A Offline
                  Anil_vvs
                  wrote on last edited by
                  #8

                  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....[:)]

                  C 1 Reply Last reply
                  0
                  • A Anil_vvs

                    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....[:)]

                    C Offline
                    C Offline
                    Christian Graus
                    wrote on last edited by
                    #9

                    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

                    A 1 Reply Last reply
                    0
                    • C Christian Graus

                      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

                      A Offline
                      A Offline
                      Anil_vvs
                      wrote on last edited by
                      #10

                      Thanx a lot Chris.....will try that...:)

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups