If that is what I should use, then what is wrong with my code.
It doesn't compile. I thought I could use a structure for a list.
Code:
// linked list
#include <iostream.h>
#include <conio.h>
#include <process.h>
#include <fstream>
#include <list>
using namespace std;
const int SIZE=81;
class linklist
{
private:
struct link
{
short age;
short weight;
char fname[SIZE];
char lname[SIZE];
char ssnumber[SIZE];
};
int x;
public:
linklist();
~linklist();
};
linklist::linklist()
{
link Data;
list<Data> Data1;
list<Data> Data2;
}
linklist::~linklist()
{//(******************)
}//(******************)
void main()
{
}
I get the following error when trying to compile.
error C2974: 'std::list' : invalid template argument for '_Ty', type expected
It errors on both list declarations. Is there an error in my syntax?
[Edit1]
I just fixed the constructor and it removed the errors.
Code:
//link Data;
list<link> Data1;
list<link> Data2;
I eliminated the Data decloration and replaced it with the struct name link.
(1) Is this a valid list decloration?
(2) If not what is wrong with it? It compiles, but I haven't been able to write the remainder of the program yet to test it.
(3) Does this instantiate two identical empty lists called Data1 and Data2?
[/Edit1]
[Edit2]
Why doesn't this work to assign details to the list?
Code:
linklist::linklist()
{
list<link> Data1;
list<link> Data2;
Data1.fname.push_front("john");
}
I even tried to replace the field in red with this below and it still doesn't work. What is wrong with it?
Code:
Data1.insert(Data1.fname.push_front("john");
I have also tried this below and it also does not link.
Code:
link Node;
list<link> Data1;
list<link> Data2;
Data1.Node.push_front("john");
error C2228: left of '.push_front' must have class/struct/union type
error C2039: 'Node' : is not a member of 'std::list<_Ty,_Ax>'
with
[
_Ty=linklist::link,
_Ax=std::allocator<linklist::link>
]
These errors have completely lost me.
What do they mean?
Think I should have started a new thread for these questions?
[/Edit2]