From: "Luismurf" Newsgroups: comp.os.msdos.djgpp Subject: object oriented Lines: 170 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.00.2615.200 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2615.200 Message-ID: Date: Wed, 23 May 2001 13:10:51 GMT NNTP-Posting-Host: 213.224.110.186 X-Complaints-To: abuse AT pandora DOT be X-Trace: afrodite.telenet-ops.be 990623451 213.224.110.186 (Wed, 23 May 2001 15:10:51 MET DST) NNTP-Posting-Date: Wed, 23 May 2001 15:10:51 MET DST Organization: Telenet Internet To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Hey smart people, This is my first attempt of an employee list. classes variables person naam (name) | +bediende (=servant) wedde (loan) | | | +verkoper (=salesman) verkoopcijfer (items saled) | +arbeider (=worker) uur (hours worked) loon (loan/hour) hmm, well I hope you'll get the idea ;-) How can i compile this in djgpp? Do I have to make a project or do I have to link these files. And how do you do all this in djgpp? Please help me out! here's my source: ---person.h------------------------------ #ifndef PERSON.H #define PERSON.H class person { protected: file://subclasses kunnen die zien char naam[25]; double salaris; public: virtual void display(void); }; #endif ------------------------------------------ ---person.cpp---------------------------- #include #include "person.h" // This method should never be called. If it is ever // called, it is considered an error. void person::display(void) { cout << "person::display - missing subclass method\n"; } ------------------------------------------ ---beroep.h------------------------------ #ifndef BEROEP.H #define BEROEP.H file://Hier worden drie subclasses van person gemaakt. file://bediende, arbeider en verkoper #include "person.h" class bediende : public person { double wedde; public: void init_data(char in_naam[], double in_wedde); void display(void); }; class arbeider : public person { double uur; double loon; public: void init_data(char in_naam[], double in_uur, double in_loon); void display(void); }; class verkoper : public bediende { double verkoopcijfer; public: void init_data(char in_naam[], double in_wedde, double in_verkoopcijfer); void display(void); }; #endif ------------------------------------------ ---beroep.cpp---------------------------- #include #include #include "person.h" #include "beroep.h" void bediende::init_data(char in_naam[], double in_wedde) { strcpy(naam,in_naam); salaris = in_wedde; } void bediende::display(void) { cout << "Bediende --> " << naam << " verdient " << salaris <<".\n"; } void arbeider::init_data(char in_naam[], double in_uur, double in_loon) { strcpy(naam,in_naam); salaris = in_uur*in_loon; } void arbeider::display(void) { cout << "Arbeider --> " << naam << " verdient " << salaris << ".\n"; } void verkoper::init_data(char in_naam[], double in_wedde, double in_verkoopcijfer) { strcpy(naam,in_naam); salaris = in_wedde+in_verkoopcijfer*0.01; } void verkoper::display(void) { cout << "Verkoper --> " << naam << " verdient " << salaris << ".\n"; } ------------------------------------------ ---bereken.cpp--------------------------- #include #include "person.h" #include "beroep.h" person *staff[10]; int main() { bediende *bedpt; arbeider *arbpt; verkoper *verpt; bedpt = new bediende; bedpt->init_data("Albert",40000.0); staff[0]=bedpt; /* arbpt = new arbeider; arbpt->init_data("Cyriel",150,300.0); staff[1]=arbpt; verpt = new verkoper; verpt->init_data("Bea",20000.0,1000000.0); staff[2]=verpt; for (int index=0;index<3;index++) { staff[index]->display(); } */ staff[0]->display(); cout << "End of list\n"; return 0; } ------------------------------------------ ~END OF SOS~