Subject: A problem from Professional C++ by Solter,Kepler
Posted By: tanchonghui Post Date: 1/14/2006 12:10:41 AM
Hi. Can anyone help with this?

I implemented the code found on p.29 - 41 of the book "Professional C++" by Solter and Kepler.

My C++ compiler gives the following error message when it's compiling Database:
_____________________________________________________________________
Employee& Database::getEmployee(string inFirstName, string inLastName)      
        ^

Database.cpp(51): Warning 18: implied return of Records::Database::getEmployee at closing '}' does not return value

void Database::displayAll()
   ^

Database.cpp(64): Warning 18: implied return of Records::Database::getEmployee at closing '}' does not return value
_____________________________________________________________________

These were the first lines of the error message. There were a few more lines. I can't figure out what's wrong.

Any advise?

Will be greatly appreciated.

tanchonghui
Reply By: klep Reply Date: 1/28/2006 7:12:01 PM
It looks like your compiler is having issues with the fact that getEmployee() throws an exception on the last line and doesn't return a value. Since the exception is thrown, no return value should be necessary.

To get it to compile, you can add this as the last line of that method:

return mEmployees[0];

Note that that line will never actually be executed.

I'm curious to know what compiler/verison you're using...

----
Scott J. Kleper
Author, "Professional C++"
(Wrox, 2005)
Reply By: vector Reply Date: 1/28/2006 10:42:42 PM
we need code to debug problem correctly


Go to topic 39278

Return to index page 383
Return to index page 382
Return to index page 381
Return to index page 380
Return to index page 379
Return to index page 378
Return to index page 377
Return to index page 376
Return to index page 375
Return to index page 374