say if i had one header file that defined all the function prototypes and global variables for each class..
something like

Code:

//blah.h

#ifndef _blah_h
#define _blah_h

class blah1 {
public:
int b1();
int b2();
private:
int b;
};

class blah2 {
public:
int b3();
int b4();
};

class blah3 : public blah2 {
public:
int b5();
};

#endif

does this appear correct ?

if it is correct then in my blah.cpp file where i go to actually implement these functions how would it look?

somedthing like...

Code:

//blah.cpp

#include "blah.h"

int b1() {
return 1;
}

int b2() {
return 2;
}

int b3() {
return 3;
}

int b4() {
return 4;
}

int b5() {
return 5;
}

and if that is correct, then what about when im using inheritance but the i would like to re-write a function how would it know if im calling the parents implementation of a function or a subclass'es implemetation of that function?

thanks

08-16-2004

prog-bman

Well thats not how you impliment them you have to do it like this

Code:

int blah1::b1() {
return 1;
}

int blah1::b2() {
return 2;
}

int blah2:: b3() {
return 3;
}

int blah2::b4() {
return 4;
}

int blah3:: b5() {
return 5;
}

and if your using inheritance and you want to re-write a function then you don't really need to use inheritance

08-16-2004

paperbox005

thanks for that, that way makes more sense than what i had.. teehee

Quote:

and if your using inheritance and you want to re-write a function then you don't really need to use inheritance

looks okay, but if b1() is going to do the same thing in blah1 as it does in blah2, then it doesn't need to be redeclared/redefined as it will be inherited and can be used as is. If you want b1() to do something different in blah1 than it did in blah2, then declare b1() virtual in blah2 and redeclare/redefine it in blah2.