structs

Associate
Joined
10 Nov 2007
Posts
809
Location
Southampton
hi

i have an odd problem which i cannot see the answer to and was wondering if someone could help

i have a struct in a header file

Code:
typedef struct simple{
int x;
int y;
float z;
simple *next;
}simple;

extern simple * firstSimple

for some weird reason it compiles then wont let me create the linked list

Code:
void add(list of params same as thos in struct other than pointer)
{
if (firstSimple == null)
{
 simple current = new Simple()
simple->x=x;
same for other variables

firstSimple = current}
else{
polygon * eol;
eol = firstSimple;
while (eol.next != NULL)
{eol = eol.next;}
eol.next = new simple()
eol.next->x=x;
...
...
}
}

at the end of it all i get numerous errors the main one being

error c2232 left operand has struct type use '.'

and

error c2228 left of .next must have class/struct/union

then it says at th end fatal error c1903 unable to recover from previous error(s) stopping compilation

if anyone can help me with my simple problem id be very thankfull

thanks in advance
pcdave

[/CODE]
 
hi ive made the changes however i think the compiler is stupid as its now saying NULL is an undeclared identifier then it says it cannot convert simple to simple when i create a new object of the struct in c++ and it still says simple does not have an overload member 'operator->

i know this is simple but im getting very confused any help would be much welcomed
 
Back
Top Bottom