friend declaration causes undeclared identifier
-
Windows 7, Visual Studio 2008, C++, MFC I cannot cut and paste to this forum so please exclude minor typos. Here is the first class declaration:
Class C_AR2_Messages
Public:
Class C_AR2_Messages();
~ Class C_AR2_Messages();
Private:
…
// friend void_C_Configuration_Manager( const C_AR2_Messages & );
// I found the template for this somewhere and presume that C_Configuration_Manager needs to be given the address of AR2_Messages so it can find variables declared private.
};A fragment from the definition of C_AR2_Messages:
bool C_AR2_Messages::Configure_The_Application()
{
C_Configuration_Manager *Message_Configurator; // << first error will be this line
Message_Configurator = new C_Configuration_Manager;
… }This all compiles as shown with no errors. HOWEVER: when the friend line is uncommented out the compiler complains with the error:
Quote:
C2061: ‘Message_Configurator’ : undeclared identifier.
It references that line so marked above. (Not the "friend" line in the declaration.) Since that is a pointer declaration I do not understand how the addition of the friend line causes it to become undeclared. A google search returned what seems to be a good match for this problem, but I am on a military base and the firewall says that site is prohibited. Will someone please enlighten me?
Thank you for your time If you work with telemetry, please check this bulletin board: www.irigbb.com
-
Windows 7, Visual Studio 2008, C++, MFC I cannot cut and paste to this forum so please exclude minor typos. Here is the first class declaration:
Class C_AR2_Messages
Public:
Class C_AR2_Messages();
~ Class C_AR2_Messages();
Private:
…
// friend void_C_Configuration_Manager( const C_AR2_Messages & );
// I found the template for this somewhere and presume that C_Configuration_Manager needs to be given the address of AR2_Messages so it can find variables declared private.
};A fragment from the definition of C_AR2_Messages:
bool C_AR2_Messages::Configure_The_Application()
{
C_Configuration_Manager *Message_Configurator; // << first error will be this line
Message_Configurator = new C_Configuration_Manager;
… }This all compiles as shown with no errors. HOWEVER: when the friend line is uncommented out the compiler complains with the error:
Quote:
C2061: ‘Message_Configurator’ : undeclared identifier.
It references that line so marked above. (Not the "friend" line in the declaration.) Since that is a pointer declaration I do not understand how the addition of the friend line causes it to become undeclared. A google search returned what seems to be a good match for this problem, but I am on a military base and the firewall says that site is prohibited. Will someone please enlighten me?
Thank you for your time If you work with telemetry, please check this bulletin board: www.irigbb.com
It needs a forward declaration of void_C_Configuration_Manager class. Do as follows. class void_C_Configuration_Manager; Do it in the header.