e4d Subj : Re: Class problems To : borland.public.cpp.borlandcpp From : Ed Mulroy [TeamB] Date : Sat Sep 11 2004 11:42 pm Start by cleaning up the code. The function main returns an int. It does not return void. You exit from main with a return statement such as return 0; You do NOT exit from main by calling exit. C++ functions, including constructors and destructors, that take no arguments have () and not (void). If you have a problem then post compilable source. .. Ed > Mark Manning/Muniz Eng. wrote in message > news:4143ab20$1@newsgroups.borland.com... > >I recently got the Borland C++v5.02 compiler et al. I've done work >with C++ for years but the compiler is frustrating me. > > I am making a simple "create a name" program for our D&D game and > I've made a class called "Name". It looks like this: > > ///////////////////////////////////////////////////////////////// > enum { gUC, gLC }; // Upper and lowercase ENUMs > enum { gMale, gFemale ); // Character's gender > > class Name > { > private: > > > public: > Name( void ); > ~Name( void ); > > full( void ); // Return the full name. > human( long optA ); // Create a human name. > elf( long optA ); // Create an elven name. > }; > //////////////////////////////////////////////////////////////// > > The main program looks like this: > > //////////////////////////////////////////////////////////////// > #include "main.h" > > void > main( int argc, char *argv[] ) > { > Name myName; > > printf( "gUC = %d\n", gUC ); > myName.human( gMale ); > printf( "My name is: %s\n", myName.full() ); > exit( 0 ); > } > //////////////////////////////////////////////////////////////// > > All of the functions are properly set in name.cpp. Like so: > > //////////////////////////////////////////////////////////////// > #include "main.h" > > Name::Name( void ) > { > > } > > Name::~Name( void ) > { > } > > Name::full( void ) > { > return( m_full ); > } > > Name::human( long optA ) > { > > } > > Name::elf( long optA ) > { > > } > /////////////////////////////////////////////////////////////////// > > The "main.h" file contains all of the includes to the various > classes. > > /////////////////////////////////////////////////////////////////// > #include > #include > . > . > . > #include "name.h" > /////////////////////////////////////////////////////////////////// > > Ok! Now that you have all of that information - here is the > question: > > When I compile - it likes everything. But when it reaches the > linker stage I get: > > Undefined Name::~Name() > Undefined Name::human( long optA ) > Undefined Name::full() > > I've checked all of the functions. I've tried commenting out each > of the above one after the other - no other error messages are > coming out of the linker. Also, the first printf statement does not > give an error about gUC. So I know it is getting name.h loaded. > > Why would the linker not like the functions themselves? Also, under > gcc this compiles without a problem (linux) but Borland C++ v5.02 > dies. My next plan of attack is to delete and redo the project's > file. Maybe that is the answer. I recently decided to move > everything to a separate subfolder (called Character). So maybe the > project file is messed up somehow. Unknown but if you have an idea > I'd like to hear from you. (markem@ev1.net). > > TIA to anyone who has an idea on this problem. :-) . 0