Error Message

This is a discussion on Error Message within the C++ Programming forums, part of the General Programming Boards category; I have these three files and I am obtaining the error message: NULL Undeclared. http://rafb.net/p/3u04E569.html http://rafb.net/p/hfzCT686.html http://rafb.net/p/oSxr5T24.html Anyone know why ...

  1. #1
    Registered User
    Join Date
    Mar 2007
    Posts
    32

    Error Message

    I have these three files and I am obtaining the error message:
    NULL Undeclared.

    http://rafb.net/p/3u04E569.html
    http://rafb.net/p/hfzCT686.html
    http://rafb.net/p/oSxr5T24.html


    Anyone know why I am getting these errors and how to fix them?

  2. #2
    Registered User
    Join Date
    May 2006
    Posts
    903
    1. NULL is defined in windows.h (maybe in other files too) if I recall.
    2. Using NULL is not advised. Just simply write 0 instead. It's even 3 characters less.

  3. #3
    Registered User
    Join Date
    Mar 2007
    Posts
    32
    Ok so I changed the NULLS to 0's and this is my error message now:

    make -k all
    Building file: ../CircleList.cpp
    Invoking: GCC C++ Compiler
    g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"CircleList.d" -MT"CircleList.d" -o"CircleList.o" "../CircleList.cpp"
    ../CircleList.cpp: In member function `int CircleList<Object>::sizeOfList()':
    ../CircleList.cpp:28: warning: no return statement in function returning non-void
    ../CircleList.cpp: In member function `bool CircleList<Object>::isEmpty() const':
    ../CircleList.cpp:34: warning: no return statement in function returning non-void
    Finished building: ../CircleList.cpp

    Building target: Project4.exe
    Invoking: GCC C++ Linker
    g++ -o"Project4.exe" ./CircleList.o
    /mingw/lib/libmingw32.a(main.o)(.text+0x106):main.c: undefined reference to `WinMain@16'
    collect2: ld returned 1 exit status
    make: *** [Project4.exe] Error 1
    make: Target `all' not remade because of errors.
    Build complete for project Project 4

  4. #4
    Registered User
    Join Date
    Oct 2006
    Location
    Canada
    Posts
    1,243
    ../CircleList.cpp: In member function `int CircleList<Object>::sizeOfList()':
    ../CircleList.cpp:28: warning: no return statement in function returning non-void
    your function sizeOfList in file CircleList.cpp doesnt have a return statement.

    ../CircleList.cpp: In member function `bool CircleList<Object>::isEmpty() const':
    ../CircleList.cpp:34: warning: no return statement in function returning non-void
    similar error to above error

    /mingw/lib/libmingw32.a(main.o)(.text+0x106):main.c: undefined reference to `WinMain@16'
    this one looks like you dont have a function 'int main(...)'

  5. #5
    The larch
    Join Date
    May 2006
    Posts
    3,573
    NULL is not defined in <windows.h> (well, may-be there too), but in <cstddef>. This file usually gets included by any other header you include, so most of the time there's no problem if you don't include it yourself.

  6. #6
    Registered User
    Join Date
    Mar 2007
    Posts
    32
    Ok I got that error to go away but now I'm having a problem in my main.

    The error says undefined reference to CircleList<int>::CircleList()

    Main File: http://rafb.net/p/C3Y5PO55.html
    http://rafb.net/p/T1Se6Z20.html CircleList.h
    http://rafb.net/p/sK5dUs41.html CircleList.cpp
    http://rafb.net/p/ZnC7nx52.html CircleListNode.h
    http://rafb.net/p/Y0VgQc26.html CircleListItr.h

    Does anyone know how to fix this error?

  7. #7
    Registered User
    Join Date
    Oct 2006
    Location
    Canada
    Posts
    1,243
    it means you dont have a templated constructor for CircleList. your constructor is just defined as 'public CircleList() ...'. you need to do something similar to, say, your find function declaration.

    right now you are only allowed to create CircleLists like this: CircleList myList;
    not like this:
    CircleList<int> myList;

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21