sridhar@ksuvax1.cis.ksu.edu (Srinivasan Sridhar) (07/12/89)
Hi C++ gurus, please help!! I have been having problems with dtors (being new to c++). Here's a list of my problems, code segment and error returned. 1. Defined 2 classes in my header file 2. Included the .h file in my main and other function (2 diff files) 3. Goes thro' cfront but is flagged down by linker ( CC -o ..) Apparently the ctors were left lying around and when encountered again (in the main pgm where the .h file is included again), complained. The dtors did not get around to do their job. Can you look at this segment and give me an idea as to how my dtors should look? I am not completely sure of how my dtors should look. I tried these two basic dtors and they don't seem to do anything. 1. use standard ~class_name(); without any arguments ( I knew this woludn't do much ) 2. delete all objects serving as arguments to the class. Can someone give me guidelines as to how my dtors should look? please e-mail your appreciated suggestions to my address below. thanks in advance, sridhar sridhar@ksuvax1.cis.ksu.edu -------------------------------------------------------------------------- //------------------------------------------------------ // definition of primitive - can be // a rectangular solid or hole //------------------------------------------------------ class primitive { double length, width, height; double diameter, depth; public: primitive(double lth, double wid, double hei); primitive(double dia, double dep); primitive() {length = width = height = 0;} ~primitive(); }; //------------------------------------------------------ // definition of compound: can be the // following combinations: // 1. primitive + primitive // 2. primitive + compound // 3. compound + compound //------------------------------------------------------ class compound { primitive *b_prim, *t_prim; compound *b_comp, *t_comp; int b_mat_face, t_mat_face; origin* orient; public: compound(primitive* base, primitive* top, int bs_fc, int tp_fc, origin* tp_or); compound(compound* base, primitive* top, int bs_fc, int tp_fc, origin* tp_or); compound(compound* base, compound* top, int bs_fc, int tp_fc, origin* tp_or); compound() {b_prim = t_prim = 0; t_comp = b_comp = 0;} ~compound(); void query_comp(); }; compound::compound(primitive* base, primitive* top, int bs_fc, int tp_fc, origin* tp_or) { b_prim = base; t_prim = top; b_mat_face = bs_fc; t_mat_face = tp_fc; orient = tp_or; } compound::compound(compound* base, primitive* top, int bs_fc, int tp_fc, origin* tp_or) { b_comp = base; t_prim = top; b_mat_face = bs_fc; t_mat_face = tp_fc; orient = tp_or; } compound::compound(compound* base, compound* top, int bs_fc, int tp_fc, origin* tp_or) { b_comp = base; t_comp = top; b_mat_face = bs_fc; t_mat_face = tp_fc; orient = tp_or; } ----------------------------------------------------------------------------- Error Code Returned ----------------------------------------------------------------------------- __primitive__ctorFD_D_D__: menu(data_input.c.o): multiply defined __primitive__ctorFD_D__: menu(data_input.c.o): multiply defined __compound__ctorFPCprimitive__PCprimitive__I_I_PCorigin___: menu(data_input.c.o): multiply defined __compound__ctorFPCcompound__PCprimitive__I_I_PCorigin___: menu(data_input.c.o): multiply defined __compound__ctorFPCcompound__PCcompound__I_I_PCorigin___: menu(data_input.c.o): multiply defined