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. C / C++ / MFC
  4. Help out with compiler error C2327

Help out with compiler error C2327

Scheduled Pinned Locked Moved C / C++ / MFC
helpdatabasewindows-adminquestion
6 Posts 4 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.
  • C Offline
    C Offline
    Chris Meech
    wrote on last edited by
    #1

    I'm having the compiler give me

    error C2327: 'ABC::m_strErrorMessageText' : is not a type name, static, or enumerator

    And this is likely because I'm not putting the code together just the way it wants it. :) Here's the code

    class ABC
    {
    public:
    CString m_strErrorMessageText;
    const char* GetErrorMessageText(){ return ( (const char*)m_strErrorMessageText ); }

    class DEF
    {
    public:
    enum tagSource
    { INIT,
    TERMINATE,
    OPEN,
    SQL
    } Source;
    char m_lpErrorText[256];

    DEF(tagSource src){Source = src;}
    

    };

    class GHI
    {
    public:
    error-> GHI() { m_strErrorMessageText = "Registry Information is missing. Please run BATCH_CONFIG.EXE to correct."; }
    };

    This code is to house various exceptions that may occur within a library and I'm trying to let each of the different exception types, DEF, GHI put text into the ABC::m_strErrorMessageText member in anyway they want to. The consumers of the library can then decide what exception types they wish to catch and simply use the ABC::GetErrorMessageText in order to get meaningful information. Any ideas on what I might still need to be doing here? Thanks.

    Chris Meech I am Canadian. [heard in a local bar]

    L M 2 Replies Last reply
    0
    • C Chris Meech

      I'm having the compiler give me

      error C2327: 'ABC::m_strErrorMessageText' : is not a type name, static, or enumerator

      And this is likely because I'm not putting the code together just the way it wants it. :) Here's the code

      class ABC
      {
      public:
      CString m_strErrorMessageText;
      const char* GetErrorMessageText(){ return ( (const char*)m_strErrorMessageText ); }

      class DEF
      {
      public:
      enum tagSource
      { INIT,
      TERMINATE,
      OPEN,
      SQL
      } Source;
      char m_lpErrorText[256];

      DEF(tagSource src){Source = src;}
      

      };

      class GHI
      {
      public:
      error-> GHI() { m_strErrorMessageText = "Registry Information is missing. Please run BATCH_CONFIG.EXE to correct."; }
      };

      This code is to house various exceptions that may occur within a library and I'm trying to let each of the different exception types, DEF, GHI put text into the ABC::m_strErrorMessageText member in anyway they want to. The consumers of the library can then decide what exception types they wish to catch and simply use the ABC::GetErrorMessageText in order to get meaningful information. Any ideas on what I might still need to be doing here? Thanks.

      Chris Meech I am Canadian. [heard in a local bar]

      L Offline
      L Offline
      led mike
      wrote on last edited by
      #2

      Chris Meech wrote:

      GHI() { m_strErrorMessageText = "Registry Information is missing. Please run BATCH_CONFIG.EXE to correct."; }

      Well GHI either needs an instance of ABC or you need to make that CString a static member of ABC. However based on your last comments in the post I have doubts about your design.

      C 1 Reply Last reply
      0
      • C Chris Meech

        I'm having the compiler give me

        error C2327: 'ABC::m_strErrorMessageText' : is not a type name, static, or enumerator

        And this is likely because I'm not putting the code together just the way it wants it. :) Here's the code

        class ABC
        {
        public:
        CString m_strErrorMessageText;
        const char* GetErrorMessageText(){ return ( (const char*)m_strErrorMessageText ); }

        class DEF
        {
        public:
        enum tagSource
        { INIT,
        TERMINATE,
        OPEN,
        SQL
        } Source;
        char m_lpErrorText[256];

        DEF(tagSource src){Source = src;}
        

        };

        class GHI
        {
        public:
        error-> GHI() { m_strErrorMessageText = "Registry Information is missing. Please run BATCH_CONFIG.EXE to correct."; }
        };

        This code is to house various exceptions that may occur within a library and I'm trying to let each of the different exception types, DEF, GHI put text into the ABC::m_strErrorMessageText member in anyway they want to. The consumers of the library can then decide what exception types they wish to catch and simply use the ABC::GetErrorMessageText in order to get meaningful information. Any ideas on what I might still need to be doing here? Thanks.

        Chris Meech I am Canadian. [heard in a local bar]

        M Offline
        M Offline
        Mike Dimmick
        wrote on last edited by
        #3

        You don't have a reference to an ABC object inside GHI's constructor. m_strErrorMessageText is an instance variable, not a static variable, so you need an ABC pointer/reference/object. Nested classes are only a definition scope - you don't automatically get a GHI instance member of ABC, for example.


        DoEvents: Generating unexpected recursion since 1991

        C 1 Reply Last reply
        0
        • M Mike Dimmick

          You don't have a reference to an ABC object inside GHI's constructor. m_strErrorMessageText is an instance variable, not a static variable, so you need an ABC pointer/reference/object. Nested classes are only a definition scope - you don't automatically get a GHI instance member of ABC, for example.


          DoEvents: Generating unexpected recursion since 1991

          C Offline
          C Offline
          Chris Meech
          wrote on last edited by
          #4

          Mike, thanks for your excellent response. It explains things exactly and coupled with led mike's response, I'm going to have to re-design things. Not sure why the original designer used the nested classes. It seems superflous considering the original design had no members for the ABC class. Appreciate the quick explanation and help.

          Chris Meech I am Canadian. [heard in a local bar]

          C 1 Reply Last reply
          0
          • L led mike

            Chris Meech wrote:

            GHI() { m_strErrorMessageText = "Registry Information is missing. Please run BATCH_CONFIG.EXE to correct."; }

            Well GHI either needs an instance of ABC or you need to make that CString a static member of ABC. However based on your last comments in the post I have doubts about your design.

            C Offline
            C Offline
            Chris Meech
            wrote on last edited by
            #5

            Thanks. Based upon your's and Mike's reply, I am going to have rethink my design. As well as remember a little more about nested classes. :-O

            Chris Meech I am Canadian. [heard in a local bar]

            1 Reply Last reply
            0
            • C Chris Meech

              Mike, thanks for your excellent response. It explains things exactly and coupled with led mike's response, I'm going to have to re-design things. Not sure why the original designer used the nested classes. It seems superflous considering the original design had no members for the ABC class. Appreciate the quick explanation and help.

              Chris Meech I am Canadian. [heard in a local bar]

              C Offline
              C Offline
              carrivick
              wrote on last edited by
              #6

              If you are using nested class then consider using 'friend' to control acess to members of the other classes. But you will still need a pointer/reference to access the in the first place.

              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