Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

 
 
Thread Tools Display Modes
Prev Previous Post in Thread   Next Post in Thread Next
Old Feb 22nd, 2008, 10:10 AM   #1
deanosrs
Programmer
 
deanosrs's Avatar
 
Join Date: Apr 2006
Location: Bristol, UK
Posts: 31
Rep Power: 0 deanosrs is on a distinguished road
Send a message via MSN to deanosrs
two classes, call each others functions - how?!!

Hi,
I'm just trying to get two classes to succesfully be able to call functions within each others class. So I effectively have:
// in A's header file
class A {
public:
  B *b;
  void a_function(); // in this function, there's the line b->b_function2
  void a_function2();
};

// in B's header file
class B {
public:
  A *a;
  void b_function(); // in this function, there's the line a->a_function2
  void b_function2();
};
The problem I have at the moment is that I have to include in each header file, the other header file, which it doesn't like. I've also tried forward class definitions, but this doesn't work either, because the line class B; in A's header file isn't sufficient to tell A that B has a function called b_function2().

Any ideas? This has troubled me for a while and is a very difficult problem to google!!
deanosrs is offline   Reply With Quote
 

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Using internal classes in STL functions manannan C++ 4 May 31st, 2006 1:25 AM
What is the point of pure virtual functions? aznluvsmc C++ 12 Apr 14th, 2006 6:48 PM
Could some please explain classes to me... TCStyle C++ 10 Feb 20th, 2006 3:51 PM
Exporting Functions victorsk Visual Basic 1 May 18th, 2005 2:32 PM
User-defined creatNode and deleteNode functions for a doubly-linked list jgs C 2 Apr 28th, 2005 8:53 AM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 3:12 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC