Thread: compiler doesn't recognize my friend

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Nov 2006
    Posts
    519

    compiler doesn't recognize my friend

    Hi all,

    Code:
    #include "CallbackTimer.h" // declares callbackfun
    
    namespace nsScheduler{
    
    class Scheduler : boost::noncopyable
    {
    	friend class Job; 
    	friend class WorkerThread;
    	friend VOID CALLBACK callbackfun( PVOID param, BOOLEAN timer_or_wait_fired );
           //I want to allow that function access to member function onTimerTick()
    
           void onTimerTick();
           //.....
    public:
           //...
    };
    
    }//namespace

    Code:
    //CallbackTimer.h
    
    VOID CALLBACK callbackfun( PVOID param, BOOLEAN timer_or_wait_fired );
    
    namespace nsScheduler{
    
    class Scheduler;
    
    class CallbackTimer :boost::noncopyable
    {
    //...
    }
    
    
    
    //CallbackTimer.cpp
    
    #include "CallbackTimer.h"
    
    #include "Scheduler.h"
    
    namespace nsScheduler{
    
    //...
    }
    
    VOID CALLBACK 
    callbackfun( PVOID param, BOOLEAN timer_or_wait_fired )
    {
    	( (nsScheduler::Scheduler*)param)->onTimerTick();
    }
    but MSVC says:

    .\CallbackTimer.cpp(48) : error C2248: 'nsScheduler::Scheduler::onTimerTick' : cannot access private member declared in class 'nsScheduler::Scheduler'




    Does anybody has an idea why my friend decleration is ignored?

    Thank you in advance!
    Last edited by pheres; 12-05-2008 at 10:53 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem building Quake source
    By Silvercord in forum Game Programming
    Replies: 16
    Last Post: 07-11-2010, 09:13 AM
  2. Problem with friend class declaration in a namespace
    By Angus in forum C++ Programming
    Replies: 2
    Last Post: 12-09-2008, 01:29 PM
  3. Problem with friend functions in templated linked list
    By Strait in forum C++ Programming
    Replies: 2
    Last Post: 03-13-2005, 04:24 PM
  4. compiler gone haywire?!
    By patito12 in forum C Programming
    Replies: 5
    Last Post: 11-13-2004, 06:18 AM
  5. Declare a template class as a friend?
    By AH_Tze in forum C++ Programming
    Replies: 11
    Last Post: 05-19-2004, 09:24 PM