gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

C/C++ > has no member named error

#172151 - Azenris - Tue Jan 19, 2010 5:32 pm

I have a class within a lib

Code:
// ================================================================================
// CLASS: CStateManager
class CStateManager : public IManager
{
public:
   CStateManager(void);
   ~CStateManager(void);

   // ============================================================================
   // PUBLIC FUNCTIONS:
public:
   void   Initialise(void);
   void   Release(void);
   void   Reset(void);

   void   Update(void);

   void         SetState(IState *pState);
   void         SetLastState(void);
   inline bool      StateHasChanged(void) const {return m_stateChanged;}
   inline bool      HasActiveState(void) const {return m_pCurrentState != NULL;}
   inline IState   *GetLastState(void) const {return m_pLastState;}

   // ============================================================================
   // PRIVATE VARIABLES:
private:
   IState *m_pCurrentState;      // the currently running state
   IState *m_pLastState;         // the last used state
   bool m_stateChanged;         // indicates whether the state changed this frame
};


I can call SetState, StateHasChanged, HasActiveState, GetLastState
but when i try to call SetLastState (one i recently added) it says "error: 'class CStateManager' has no member named 'SetLastState'"

Code:
// ================================================================================
// SetLastState:
void CStateManager::SetLastState(void)
{
   SetState(GetLastState());
}


Its called with

Code:
GetStateManager()->SetLastState();

Code:
inline CStateManager      *GetStateManager(void) const {return m_pStateManager;}

Code:
CStateManager *m_pStateManager;            // state manager, handles the different game states


I tried a full rebuild on both the lib and main project. I tried reopening the editors. I also tried renaming SetLastState to "Boo", nothing worked. Is it something simple I'm missing? :(
_________________
My Homebrew Games

#172152 - elhobbs - Tue Jan 19, 2010 5:42 pm

is your project using the latest header file from your library?

#172154 - Azenris - Tue Jan 19, 2010 8:41 pm

Ok, i made a silly mistake, I'm surprised it isn't picked up as an error. i seem to have two files for the header of statemanager, and it was using one I didn't notice I had, and so was outdated.

Surely it should warn of two files with the same name in different directories, anyway ty, noticed it after your post.
_________________
My Homebrew Games

#172155 - sajiimori - Tue Jan 19, 2010 10:27 pm

Having multiple headers with the same name is sometimes intentional. For instance, if an engine is shared across multiple projects, it might supply default versions of some headers, allowing the game code to override and customize individual headers without modifying the engine directly.

#172156 - kusma - Wed Jan 20, 2010 12:58 am

Azenris wrote:
Surely it should warn of two files with the same name in different directories

No, it shouldn't.

#172157 - Azenris - Wed Jan 20, 2010 1:19 am

kusma wrote:
Azenris wrote:
Surely it should warn of two files with the same name in different directories

No, it shouldn't.


I realise that now from sajiimori's post :)
_________________
My Homebrew Games