Public Group

#### Archived

This topic is now archived and is closed to further replies.

This topic is 5566 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

im not sure how to use this properly any one got some advice?
#pragma once
#define WINDOWS_LEAN_AND_MEAN
#include <windows.h>

{
protected:
bool    d_bIsRunning;

public:

void Begin();
void End();
bool IsRunning();

};

#include"cThread.h"
{
d_bIsRunning = false;
}
{
End();
}
{
#if defined( _WIN32 ) && defined( _MT )
End();  // just to be safe.

0,
this,
0,
{
// Arrooga! Dive, dive!  And deal with the error, too!

}
d_bIsRunning = true;
#endif
}
{
return 0;
}
{
}

{
#if defined( _WIN32 ) && defined( _MT )
{
d_bIsRunning = false;
}
#endif
}
{
return(d_bIsRunning);
}

#include<iostream.h>
{
mData = 0;
}
{
mData += amount;
}
{
End();
}
{
cout<<mData<<endl;
return 0;
}

#include"cThread.h"
{
public:
int mData;
};

#include"mThread.h"
#include<iostream.h>
void main()
{
cout<<"hello"<<endl;
x->Begin();
cout<<x->mData<<endl;
q->Begin();
}


im not sure how to get it working so that begin actually starts the thread, which should increment mData then output it then end. the cThread class is originally from FlipCode so it should work i just dont knwo hwo to get it working.

##### Share on other sites
I didnt follow your code through all the way and i am no c++ expert, but it seems that you didnt include the cThread.h in you main cpp file... you are declaring an object reference and allocation new memory to it, but the object reference is of an object that doesn''t exist as far as that code is concerned - i.e. no cThread class.

##### Share on other sites
quote:
Original post by kalash
I didnt follow your code through all the way and i am no c++ expert, but it seems that you didnt include the cThread.h in you main cpp file... you are declaring an object reference and allocation new memory to it, but the object reference is of an object that doesn''t exist as far as that code is concerned - i.e. no cThread class.

I believe .h files cannot include headers,. so it is being ignored. You should use sentry statements at the top of your main file to make sure that everything is correct. For example:
#ifndef __CTHREAD_H__#define __CTHREAD_H__#endif

Scott Simontis
e-mail:ageofscott@comcast.net
AIM:ssimontis

##### Share on other sites
Of course .H files can include headers, but they shouldn''t.

##### Share on other sites
quote:
Original post by Valderman
Of course .H files can include headers, but they shouldn't.

Don't be stupid... why not?

[ Google || Start Here || ACCU || STL || Boost || MSDN || GotW || CUJ || MSVC++ Library Fixes || BarrysWorld || E-Mail Me ]

[edited by - Lektrix on September 22, 2003 10:58:01 AM]

##### Share on other sites
quote:
Original post by vaneger
im not sure how to use this properly any one got some advice?
im not sure how to get it working so that begin actually starts the thread, which should increment mData then output it then end.
the cThread class is originally from FlipCode so it should work i just dont knwo hwo to get it working.

Are you linking against multithreaded libs? Note that the MT code only gets compiled into your program if _WIN32 and _MT are defined, so make sure you choose the correct project settings.
quote:
Original post by kalash
you are declaring an object reference and allocation new memory to it, but the object reference is of an object that doesn''t exist as far as that code is concerned

What on earth gives you that idea? If the compiler could not see the class definition at point of instantiation, it would not know how much memory it needed to allocate, and would complain quite loudly.

##### Share on other sites
ok the dude at flipcode messed up a bit when he wrote cThread. when he called create thread he didnt pass the proper cThreadProc address of cThreadProc(this). it works now though

1. 1
2. 2
Rutin
19
3. 3
khawk
18
4. 4
A4L
14
5. 5

• 12
• 16
• 26
• 10
• 44
• ### Forum Statistics

• Total Topics
633767
• Total Posts
3013735
×