Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!samsung!brutus.cs.uiuc.edu!apple!voder!wlbr!awds26!mh From: mh@awds26.imsd.contel.com (Mike Hoegeman) Newsgroups: comp.lang.c++ Subject: how do you define classes that refer to each other ??? Message-ID: <49689@wlbr.IMSD.CONTEL.COM> Date: 20 Mar 90 00:04:01 GMT Sender: news@wlbr.IMSD.CONTEL.COM Reply-To: mh@awds26.UUCP (Mike Hoegeman) Organization: Contel FSD, Westlake Village, CA Lines: 47 This is probably a stupid question, but here goes anyway. how do you set up two classes that refer to each other ? Here's a simple example to demonstrate my problem. class thing { int data[5]; void execute(stack &s) { s.push(this); } } class stack { stack_store thing[500]; int si; private: void push(thing *t); stack() { si = 0; } } void stack::push(thing *t) { stack_store[si++] = *t; } main() { thing mything; stack mystack; mything.execute(); } Now, the question is. How do I properly forward declare class 'stack' to class 'thing' so that everybody is happy ? I have the stroustrup C++ book as well as the Dewhurst/Stark C++ book so an admonishing "you'll find this on page in Stroustrup you moron" is fine :-). I've scanned through these two books but have not found the answer. thanks, - mike hoegeman, mh@wlbr.imsd.contel.com