Hey there,
I was just wondering if you could give me any insight in how to correctly use std::list from the STL.
I ask this because in my programming studies I was asked to make a LinkedList template class (so I could understand the principals of dynamic memory and doubly-linked lists), since then I've always used that.
I tried using std::list the other day for the first time and I got the error:
include\xmemory0(419): error C2039: 'value_type' : is not a member of 'DocRef'.
I thought there might be a name-clash somewhere but, I wasn't using the std namespace.
I've run out of ideas. I was going to revert back and keep using my template but, I thought I should ask the correct way to use std::list. I assume I'm doing something wrong.
Here is my code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
|
//=========================================================
// Name: DocRef struct
// Desc: A struct used as a reference object to the
// pathway of a virtual document
//=========================================================
struct DocRef
{
std::string mName;
std::string mPathway;
};
//=========================================================
// Name: Folder Struct
// Desc: The virtual representation of a folder in a
// Archive Drawer. Contains a list of sub-folders
// and Document Pathways.
//=========================================================
struct Folder
{
std::string mName;
std::list<Folder, DocRef> mContents;
};
//=========================================================
// Name: Drawer Struct
// Desc: The virtual representation of a draw in an
// Archive. Contains a list of folders, which
// point to Document Pathways.
//=========================================================
struct Drawer
{
std::string mName;
std::list<Folder, DocRef> mContents;
};
//=========================================================
// Name: Archive Class
// Desc: The Class Declaration of the Archive type,
// used as a directory for document files.
//=========================================================
class Archive
{
public:
// Constructors
//---------------------------------------------
Archive();
Archive(const Archive& rhs);
// Destructors
//---------------------------------------------
~Archive();
// Overloaded Operators
//---------------------------------------------
Archive& operator=(const Archive& rhs);
// Methods
//---------------------------------------------
void setName();
void setPath(char pathway[]);
void reset();
private:
std::string mName;
std::string mPathway;
std::list<Drawer> mContents;
std::list<Drawer>::iterator mIter;
};
|
I'm still working on the project (as you can probably tell) so, the header is incomplete.
I'm not sure why but, from reading the errors it appears that std::list has some issue with my "DocRef" struct.
Can you help me?