|
From: <gi...@li...> - 2001-08-30 17:05:21
|
Hi, I took a quick look at your source code, there is something that needs to be fixed but first here is why you get the 3 "undefined" errors. As the word "undefined" says, there is some definition missing: your program is made up of 4 source files, this means that to build the executable you need to compile the 4 files and link them together. If you use the Dev-C++ IDE you should create a project, add the 4 source files to it and then go ahead with a compilation (which in the case of Dev-C++ implies also the linking step). I think that you just opened the file "gradefv.cpp" in the edit window of Dev-C++ and then went on with a compilation: since you did not specify where the definitions of the 3 functions "read", "compare" and "grade" are, the linker issued the "undefined" error. As I said before there is something more: - I looked at the file "grade.cpp" but saw no definition for the function "double grade(const Student_info&)": this means that even if you link "grade.cpp", there will still be an "undefined" error about this function. - To be consistent with your programming style, the file "median.cpp" should include the file "median.h" Just in case you are not using the Dev-C++ IDE, but are familiar with the "make" program and the CLI interface of mingw, I attached the files "gradefv.mk" and "b.bat" which you could use to build your program. At 12.20 29/08/01 -0700, you wrote: >I was trying to compile a small program when the following messages popped >up in the "Compiler and Linker Output" window: > >c:\windows\TEMP\cc16bbgb.o(.text+0x110):gradefv.cpp: undefined reference >to `read(istream &, Student_info &)' > >c:\windows\TEMP\cc16bbgb.o(.text+0x194):gradefv.cpp: undefined reference >to `compare(Student_info const &, Student_info const &)' > >c:\windows\TEMP\cc16bbgb.o(.text+0x2b5):gradefv.cpp: undefined reference >to `grade(Student_info const &)' > >The compilation was said to be successful though. But there was zero output. > >By the way, I am learning C++ on my own by reading Accelerated C++ >Practical Programming by Example by A. Koenig and B. Moo. This problem >occurred when I attempted to compile the example program. I checked the >authors' source code too and attempted to run theirs. Their program had >the same problem. What could be the problem? Help will be appreciated. > >jyz -- gisan gi...@li... |