View Single Post
  #4 (permalink)  
Old July 6th, 2005, 01:48 AM
klep klep is offline
Authorized User
Join Date: Oct 2004
Location: San Francisco, CA, .
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts

Thank you for the additional info.

I downloaded devcpp and reproduced the error (I hadn't ever actually used this IDE before -- it's nice!)

The error you get is actually correct -- the IDE is compiling the EmployeeTest class. Since this class #includes "Employee.h", it gets the declaration for the Employee class and all of its associated methods. However, when the linker tries to generate the application, it can't find the *definition* of the Employee class and its methods. It knows the names, but never saw or compiled the implementations.

The solution is to add the Employee.cpp file to the project. From your description, it sounds like maybe you didn't create a project in Dev-C++. Doing so is necessary because otherwise it will just try to compile and run a single file. Here are the steps to create the project and run the example:

1) File -> New -> Project...
2) Choose "Console Application" and click OK
3) Save the project somewhere
4) The project starts you off with a main.cpp. In the "project" tab in the left sidebar, right click on 'main.cpp' and select "Remove File". The project is now empty.
5) Right click on Project1 (or whatever your project is called) under the 'project' tab in the left sidebar and select "Add to Project".
6) Navigate to the EmployeeDB folder and select Employee.cpp and click OK
7) Repeat step 6 selecting EmployeeTest.cpp
8) Execute -> Compile and Run

At this point, you'll see the files compile, link, and the console window should come up and disappear. That's because it runs so fast that you don't have a chance to see the output. To see the output, you can either run in debug mode, stepping through each line, or you can run the .exe file from a command window. My executable wound up in C:\Dev-Cpp\Project1.exe

Also, the reason that the main() is commented out in EmployeeTest is because the *real* program for EmployeeDB is found in UserInterface.cpp. I didn't want the two mains to collide but I wanted to leave the test code in for reference. I apologize if that was confusing. As long as you're just using Employee.cpp and EmployeeTest.cpp, go ahead and uncomment the code.

Hope this helps!


Scott J. Kleper
Author, "Professional C++"
(Wrox, 2005)