Subj : Re: Class problems To : borland.public.cpp.borlandcpp From : Mark Manning Date : Sat Sep 11 2004 11:55 pm I am replying for two reasons: 1. To let you know that I am now home and can send you a zipped file of everything. 2. To say that, after thinking about it on the way home I now understand your posting about compilable code. Let me address this. The reason I did not place any code in the functions is because: 1)I have already tried putting #if 0/#endif around all of the code in the functions. It doesn't matter if I remove the code completely or comment it out or put the #if 0/#endif, 2)Originally, the main program had nothing in it. When all commands are removed from the main program everything compiles and does not complain. Only when I attempt to use the class does the IDE complain, and 3)It is the linker and not the compiler which is complaining. The compiler seems to like everything just fine. This is why I stated that I was going to try redoing the project file. I have already had to do this once before because the Project file started acting very strange. Not being able to find/locate the source files and such. So that is what I am going to try now that I have gone through all of the permutations with the source code I am going outside of the source and seeing if one of the other files used by the IDE is causing a problem. If not - what can I say? 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. :-) > > > .