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. ATL / WTL / STL
  4. friend declaration causes undeclared identifier

friend declaration causes undeclared identifier

Scheduled Pinned Locked Moved ATL / WTL / STL
c++helpcsharpvisual-studiocom
2 Posts 2 Posters 2 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.
  • B Offline
    B Offline
    bkelly13
    wrote on last edited by
    #1

    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

    S 1 Reply Last reply
    0
    • B bkelly13

      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

      S Offline
      S Offline
      Subrat 4708266
      wrote on last edited by
      #2

      It needs a forward declaration of void_C_Configuration_Manager class. Do as follows. class void_C_Configuration_Manager; Do it in the header.

      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