I am trying to compile a linked list implementation file that includes a linked list header file. I get this error.
In function `_start':
: undefined reference to `main'
collect2: ld returned 1 exit status
I know that since the implementation file is a cpp file without a main function, it needs some sort of special command when compiling, but I don't know what it is.
Oh. My professor has shown in his lecture sample code in this same format with the class interface in a header file and the class implementation in a cpp file that includes the header file.
Oh. My professor has shown in his lecture sample code in this same format with the class interface in a header file and the class implementation in a cpp file that includes the header file.
In real world usage those files would be included in a larger project, which will have a main function somewhere else. Or, you could make them into a library instead of an executable program, you just have to change your linker settings.
int main() is like an entry point to your's program.
You can put the implementation file at main file but not recommended or include header file at main file.
Bookmarks