struct pair - Please Help!

This is a discussion on struct pair - Please Help! within the Windows Programming forums, part of the Platform Specific Boards category; Ok, I am baffled! I have seen the error "cannot access private member" before, but never "cannot access public member" ...

  1. #1
    Magically delicious LuckY's Avatar
    Join Date
    Oct 2001
    Posts
    856

    Unhappy struct pair - Please Help!

    Ok, I am baffled! I have seen the error "cannot access private member" before, but never "cannot access public member" and I am clueless as to how to fix this ailment!

    The error:
    Code:
    C:\Program Files\DevStudio\VC\INCLUDE\utility(14) : error C2248: 'Square::Square' : cannot access public member declared in class 'CMainWnd::Square'
    My definition of struct Square:
    Code:
      struct Square {
        int col;
        int row;
        Square(int c=-1, int r=-1) : col(c), row(r) { }
        void Set(int c, int r) { col = c; row = r; }
        bool isValid() { return col >= 0 && row >= 0; }
      };
    My typedef of ThreatPair:
    Code:
    typedef pair<Square, ThreatSquare> ThreatPair;
    The above error occurs wherever I instantiate a ThreatPair.. I'm simply doing it like this (to try figuring out the error):
    Code:
    ThreatPair tp;
    And the error points to the line of the default constructor of the pair template in the stl `utility` file... What's going on??? Please assist!

  2. #2
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,674
    Looks like you declared Square inside your CMainWnd. Try declaring Square outside of CMainWnd (VC++ doesn't handle embedded class's well) or do something like this:
    Code:
    typedef CMainWnd::Square MySquare;
    and use MySquare instead of Square.

    gg

  3. #3
    Magically delicious LuckY's Avatar
    Join Date
    Oct 2001
    Posts
    856
    That fixed it...

    Thanks much Codeplug!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Segfault with Linked List Program
    By kbrandt in forum C Programming
    Replies: 1
    Last Post: 06-23-2009, 07:13 AM
  2. Replies: 1
    Last Post: 12-03-2008, 02:10 AM
  3. newbie needs help with code
    By compudude86 in forum C Programming
    Replies: 6
    Last Post: 07-23-2006, 08:54 PM
  4. Function validation.
    By Fhl in forum C Programming
    Replies: 10
    Last Post: 02-22-2006, 07:18 AM
  5. Search Engine - Binary Search Tree
    By Gecko2099 in forum C Programming
    Replies: 9
    Last Post: 04-17-2005, 02:56 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21