Help out with compiler error C2327
-
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]
-
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]
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.
-
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]
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 -
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 1991Mike, 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]
-
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.
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]
-
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]