Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to create dynamic array of CWinThread?

Status
Not open for further replies.

Bartec

Programmer
Jan 21, 2005
54
PL
Hi!
I need to create dynamic array of CWinThread
basically my code looks like that:

CWinThread* thr = new CWinThread[5];
then,

thr[1] = AfxBeginThread(.........);<--on this I have error

Thanks for any help

Best regards

Bartek
 
on this I have error

Aah, since you didn't specify what error you got, let me guess...

[tt]no match for `CWinThread& = CWinThread*&' operator
candidates are: CWinThread& CWinThread::eek:perator=(const CWinThread&)[/tt]

Or something like that, depending on what brand of compiler you use.

The problem is in the first line, where you make an array of CWinThread objects. thr is a pointer to the first element of that array.

Then in the second line, the expression thr[ignore][1][/ignore] is a reference to the array element. The error is that you're trying to assign a CWinThread* to a CWinThread, because AfxBeginThread returns a CWinThread* that points to an object that it initialized.

What you probably want is instead to have an array of pointers. The first line should become
CWinThread **thr = new CWinThread* [ignore][5][/ignore];

That way, type of thr[1] is CWinThread* rather than CWinThread.

I REALLY hope that helps.
Will
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top