Subj : Re: Class problems To : borland.public.cpp.borlandcpp From : Mark Manning Date : Sun Sep 12 2004 01:44 am Ok, figured it out myself. :-) I had made everything in the project: myProg +---->main.cpp +----->name.cpp . . . When main.cpp compiled it could not find the subsets under it. By moving all of the sub-functions to be on the same level as main.cpp main could find them and work with them. Strange but true. Would have thought that since all of the classes are being used by the main program that they would/could be hung off of main.cpp. But no. The compiler doesn't like it like that. Ah well. And it only took me about two hours to figure this out. No book (can't find it but it is around here someplace), the SAM'S book on C++ Builder is no help, and of course none of the other books on C++ that I have help because this is something unique to Borland C++'s IDE. :-/ What can I say? Oh well, back to my tinkering with the program. :-) Mark Ed Mulroy [TeamB] wrote: > 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. :-) > > > .