Looks pretty simple, right?
Well my professor has given us a few snippets of code that seem like they would apply to this lab, but I am pretty clueless on how to get them to work. Here is what I've got so far.
#include <iostream>
using namespace std;
struct node {
int data;
node *next;
};
void main()
{
// To create a list of 10 numbers read in from the keyboard
node q = new node;
node *head;
head = q;
q->data = 10; // assume the list contains 10 numbers
for(i=0; i<10; i++)
{
node *p = new node;
cin >> p->data;
q->next = p;
q = p;
}
}
Here is my error output:
lab12.cpp(19) : error C2440: 'initializing' : cannot convert from 'node *' to 'node' No constructor could take the source type, or constructor overload resolution was ambiguous lab12.cpp(21) : error C2440: '=' : cannot convert from 'node' to 'node *' No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called lab12.cpp(22) : error C2819: type 'node' does not have an overloaded member 'operator ->' lab12.cpp(12) : see declaration of 'node' did you intend to use '.' instead? lab12.cpp(22) : error C2232: '->node::data' : left operand has 'struct' type, use '.' lab12.cpp(24) : error C2065: 'i' : undeclared identifier lab12.cpp(24) : error C2065: 'i' : undeclared identifier lab12.cpp(24) : error C2065: 'i' : undeclared identifier lab12.cpp(28) : error C2819: type 'node' does not have an overloaded member 'operator ->' lab12.cpp(12) : see declaration of 'node' did you intend to use '.' instead? lab12.cpp(28) : error C2232: '->node::next' : left operand has 'struct' type, use '.' lab12.cpp(29) : error C2679: binary '=' : no operator found which takes a right-hand operand of type 'node *' (or there is no acceptable conversion) lab12.cpp(15): could be 'node &node::operator =(const node &)' while trying to match the argument list '(node, node *)'
This stuff is a big change from what we have done previously in the semester, so I'm a bit lost.
This is one of my last assignments and I could really use some help figuring it out!
Thanks
This post has been edited by Hayling: 07 May 2009 - 06:11 PM

New Topic/Question
Reply




MultiQuote






|