0

Hi,

I'm trying to code a program that involves a double linked list. I have the linked list working but the information in the link list need to be shared between 2 different classes. Is it possible to pass a linked list as reference and manipulate it within the different classes?

i.e.

int main(void) {
    CList list;
    Class1 myObj1(list);
    Class2 myObj2(list);
    return 0;
}

class Class1 {
	public:
		Class1(CList* list) {
                    class1List = list;
                }
      protected:
           CList class1List;
};

class Class2 {
	public:
		Class2(CList* list) {
                    class1List = list;
                }
      protected:
           CList class2List;
};

I know this isnt 100% correct c++ but i just wanted to get the point of what I was trying to accomplish across. Is this or something like this possible? If not, what are my options?

Thanks!

2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by SeeTheLite
0

Er, yes you can use functions and manipulate classes in a structure; just remeber to refer to them properly i.e. list->class1->function();

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.