   Copying class pointers??
  Hmm why can''t i just copy a class pointer?For example:    class bla *foo, *foo2;    foo = new bla;    foo2 = foo;That will segfault ? why?   ------With kind regards,Sander Aerts aka DrSnugelsCrap ---------------------------mov ax, 013h; int 10h; mov ax, 0xa000h;mov es, ax; mov di, 3360; mov al, 15;stosb; mov ax, 0002h; int 21h;mov ax, 03h; int 10h; 
  remove the "class" from your statement:bla *foo; *foo2;Regards,Jeff ;  I don''t have class in my statement it was mented as example so that people knew that i was talking about class object pointers :D ;  That should not cause a seg fault.  Post more code, the problem lies elsewhere... ;  it shouldn't seg fault.  can you post your actual code?my guess is that you're doing something like: Bla *foo, *foo2;foo = new Bla();foo2 = foo;delete foo;foo2->doSomething();that's wrong because copying the pointer is just copying the pointer (i.e. the memory address).  it doesn't actually make a copy of the class.  so if you delete foo, then foo2 will be pointing to memory that no longer holds an instance of Bla.-me   [edited by - Palidine on February 9, 2004 5:42:02 PM];  class TestClass {public:  int x;  TestClass() : x(0) {};};int main() {  TestClass* tp1, * tp2;  tp1 = new TestClass();  tp2 = tp1;  cout << tp1->x << " " << tp2->x;  return 0;}This compiles and runs just fine for me (along with appropriate includes and using statements).  I''m not sure what your problem is, but I think it''s more than just your assignment statement. ;/* START CODE */msg = new msgw(0);thread = new threads; /* Init multi-threading envoirement */net = new inet(port, "0.0.0.0"); /* Init network layer */thread->net = net;/* THREAD CODE */void *threads::__client_connect_thread(void *arguments){signed int id = (signed int)arguments;printf("Socket id: %d\n", id);net->se(id, "Testing...");return(NULL);}But i was thinking maybe it's because it's called from within the thread or something?   ------With kind regards,Sander Aerts aka DrSnugelsCrap ---------------------------mov ax, 013h; int 10h; mov ax, 0xa000h;mov es, ax; mov di, 3360; mov al, 15;stosb; mov ax, 0002h; int 21h;mov ax, 03h; int 10h;[edited by - Sander Aerts on February 9, 2004 5:43:08 PM] [edited by - Sander Aerts on February 9, 2004 5:44:32 PM];  you haven''t posted nearly enough code to see what the problem is.  a multi-threaded program is a bitch to debug, but try using your debugger.   at what line exactly does your program crash?  why does it crash?  is something NULL that you think isn''t?in that code you should try something like: /* THREAD CODE */void *threads::__client_connect_thread(void *arguments){   if (net == NULL) {  printf("net was NULL and shouldn''t be\n");  return(NULL);   } else {    signed int id = (signed int)arguments;    printf("Socket id: %d\n", id);    net->se(id, "Testing...");    return(NULL);   }};  also, if your "new threads" command will also start the threads churning, then the problem is probably that the net->se code is running before you set thread->net = net;  i.e. it''s net == NULL when you call net->se.  so make sure you are checking for NULL like in my last post.also, yeah, learn to use your debugger or you will die of frustration -me ;  My guess is that __client_connect_thread (what a horrible way to name a member function) expects net to be defined and this member function is running before the assignment (thread->net = net).Rework your code so that threads constructor expects a inet pointer to a valid inet object and pass it in like:thread = new threads(new inet(port, "0.0.0.0"));This should set up the inet object pointer before the thread starts executing.But without knowing more about your code, that''s all just a guess...Regards,Jeff 