Hey guys, when i run the following code on ubuntu(code::blocks) it gives me a number of errors but when i run it on windows(code::blocks) it works fine.
line14 error:ISO C++ forbids declaration of 'link' with no type
line14 error: expected ';' before '*' token
line18 error: 'first' was not declared in this scope
line26 error: 'current' was not declared in this scope
line26 error: 'first' was not declared in this scope
line36 error: 'current' was not declared in this scope
line36 error: expected type-specifier before 'link'
line36 error: expected ';' before 'link'
line36 error: 'first' was not declared in this scope
I don't really believe he's getting those errors with that code. What he posted is valid C++ and those errors are nonsense.
the whole typedef'ing the struct thing would be a solution for C, but since this is clearly C++ it shouldn't make a difference.
I suspect he's not compiling the code he thinks he is. Maybe there are subtle differences between what he compiled on Windows and what he compiled on Ubuntu.
@Disch: yup, these are non sense but i am getting the errors even if compile the exactly same program from the terminal, and have done it a number of times.
@Disch: yup, these are non sense but i am getting the errors even if compile the exactly same program from the terminal, and have done it a number of times.
Are you compiling exactly what you posted "here" with both compilers and getting those errors?
yes.. these will come for C. And he must be compiling for C but looks c++.
on windows if the file is .cpp, it will compile fine. What about ubuntu? could you give the compile command you are using? are you sure you are including iostream?
what happens if you put this then run on g++ im just guessing btw so dont yell at me how stupid it is.
1 2 3 4 5 6 7 8 9 10 11 12
#include <iostream>
usingnamespace std;
struct link; // add this. allow to see declaration of link before link *next is used
struct link
{
int data;
link *next;
};