N
Nevyn
Hi, i've got a problem with the following declarations
file list.h
file list.h
Nevyn said:Hi, i've got a problem with the following declarations
file list.h
-----------
class listOfItem : public QPtrList<Item>
{
.
.
.
}
----
file multiple.h
--------------------
class Item
{
private:
listOfItem: list1, list2;
.
.
.
}
how should i include the above files?
whatever i tried resulted in errors
Thanks for your answer Victor but given that i must use list1 & list2 inPerhaps you should change the 'Item' to contain a pointers to lists:
class listOfItem;
class Item
{
listOfItem *list1, *list2;
...
};
That allows you to only forward-declare the class instead of having to
include the definition.
Nevyn said:Thanks for your answer Victor but given that i must use list1 & list2 in
some method of Item (e.g. count total elements in lists) i have to call
the 'new' statement for those listOfItem in the Item constructor... thus i
always end with the same problems... or am i missing something?
Nope, that was not what i was missing i was trying instead to defineYes, you're missing that you're allowed to put the Item's constructor
into a separate file and not the 'Item' class definition. The order of
compilation for Item's constructor would be
Forward-declare class listOfItem.
Define class Item.
Define class listOfItem.
Define Item::Item.
Nevyn said:[...]
Now i am wondering (just out of curiosity) is there a way to solve the
above problem without using pointers?
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.