0

My problem is:

Error 1 error C2248: 'CObject::CObject' : cannot access private member declared in class 'CObject' c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\afxwin.h 1991 1 ProcessInfo

And my code:

boost::thread timerThread(&CMainFunctions::TimerFunction, this, pid, TIMER_INTERVAL_MS, lstBox);

lstBox is MFC ListBox., my TimerFunction is:

void CMainFunctions::TimerFunction(int pid, int interval, CListBox &lstbox)

What I need to do, to edit my MFC form, or rather edit my ListBox in my form in thread?

Alexander Mashin
  • 693
  • 3
  • 14
  • 34

1 Answers1

1

The arguments supplied to the boost::thread constructor are copied. From the linked reference page:

As if thread(boost::bind(f,a1,a2,...)). Consequently, f and each an are copied into internal storage for access by the new thread.

The compiler is complaining that an attempt is made to copy a non-copyable object. As suggested in a comment by Joachim Pileborg to the question use boost::ref to prevent the copy and pass a reference to the argument instead. The argument passed by reference must exist for the lifetime of thread.

Community
  • 1
  • 1
hmjd
  • 120,187
  • 20
  • 207
  • 252