UNIX Socket FAQ

A forum for questions and answers about network programming on Linux and all other Unix-like systems

You are not logged in.

  • Index
  • » C++
  • » General C++ programming

#1 2006-07-11 03:21 PM

Lloyd
Member
Registered: 2006-02-13
Posts: 53

Re: General C++ programming

I have been confused with the following way of programming. please help me.
In my project I have a frame window and as its part 3 classes. A treeview , a window and a HTML control. Through the window I can select some directories. As soon as the selection is made the tree view must display all the HTML files in that directory. When clicking on the HTML file name in hte tree control it must be displayed in the HTML control. To carry I have used splitter windows. Now the problem comes. I dont know How to organise the classes and where to write the event handler!
As an example how can I pass the button click event in the window to the tree control. Or a click event in the tree control to the HTML control. Though these 3 are seperate classes and their objects are not related each other, it makes me confused! (I would like to write the event handler for each class in that class itself and I dont want to mess up the frame window with lots of code....)

could you please help me? Thanks in advance..
Lloyd.

Offline

#2 2006-07-12 09:22 AM

Lloyd
Member
Registered: 2006-02-13
Posts: 53

Re: General C++ programming

as an example let us assume there are 3 classes A,B and C

class A
{
 private:
   class B b;
   class C c;
};

class B
{
  private:
    .......
  public:
   ...
};


class C
{
  private:
    .......
  public:
   ...
};

If I want to invoke a method in class C from class B or vice versa.. How can I implement that correctly and effeciently in C++. Class B and C are related only through its aggregating class class A.

This concept confuses me a lot, please help me...
Thanks in advace,
  Lloyd.

Offline

#3 2006-07-12 01:16 PM

i3839
Oddministrator
From: Amsterdam
Registered: 2003-06-07
Posts: 2,239

Re: General C++ programming

Just pass along a reference of class A to both B and C, and then they know in which class they are and can reach "sibling" classes. But if A and B don't know at all about A, but only of each other, then only pass along a reference to the other class, e.g. in their constructors.

Offline

  • Index
  • » C++
  • » General C++ programming

Board footer

Powered by FluxBB