   2 classes interating?
  How can two classes interact?// Pseudoclass two;class one {    function stuff(two *t) {   t->do_stuff(this);    }}class two {    function do_stuff(one *o) {   o->draw();    }}Now, I know I can forward-declare, but how can I actually call the functions?  Is this allowed?In C++...  (MingW)EDIT:  Also, can I use references instead of pointers?   
  Usually, what you'll do is forward declare the class in your header, and have an include to the header file in your .cpp...example one.h#ifndef ONE_HEADER_GUARD#define ONE_HEADER_GUARDclass two;class one{   void stuffptr(two* in_two);   void stuffref(two& in_two);};#endiftwo.h#ifndef TWO_HEADER_GUARD#define TWO_HEADER_GUARDclass one;class two{   void stuffptr(one* in_one);   void stuffref(one& in_one);};#endifone.cpp#include "one.h"#include "two.h"void one::stuffptr(two* in_two){    in_two->do_stuff(this);}void one::stuffref(two& in_two){    in_two.do_stuff(this);}two.cpp#include "two.h"#include "one.h"void two::stuffptr(one* in_one){    in_one->do_stuff(this);}void two::stuffref(one& in_one){    in_one.do_stuff(this);}Hope this helps   ;  Try avoid this kind of circular references. In place where it is not really required, it is a major example from very very bad code.I remember it wouldn't work like this anyway. The solution is more akward, you need to do two separate files where both classes are being introduced to each other in their adjacent or one header. Then the function calls are in separate source -file, which have "seen" the class definition instead of just predefinition.references are kind of pointers too. You can freely write "one& t" (invent better names than t or o...) into parameters list, thought I don't remember how C++ compiler implements them.   ;Quote:Original post by CheeryTry avoid this kind of circular references. In place where it is not really required, it is a major example from very very bad code.I remember it wouldn't work like this anyway. The solution is more akward, you need to do two separate files where both classes are being introduced to each other in their adjacent or one header. Then the function calls are in separate source -file, which have "seen" the class definition instead of just predefinition.references are kind of pointers too. You can freely write "one& t" (invent better names than t or o...) into parameters list, thought I don't remember how C++ compiler implements them.I think the above will work...It's just that my renderer class knows all about surfaces and images and has the power to render them - but it needs to renderer text.  Since text has characters and it only does graphics it won't know about the characters and only the rectangles/images so it must call text's functions for it to draw stuff and text must call some of renderer's functions to draw correctly...As for the and o and stuff, I like short letter terms for something short and simple:function do_stuff(a &t) {    t.do_stuff();}// vs.function do_stuff(a &complex_input) {    complex_input.do_stuff();}I mean, it's not like it's doing a lot so you need to remember it, right?Thanks guys!   ;  class1.h, class2.h.forward declare the other class in each header.include both headers from each *.cpp   