O
Omer
Hi All,
I have two classes that have the same functionality, but with
different constants, e.g. database table name.
I've defined a base class that gets the constants in the constructor,
and maintain the functionality. It works fine, but not very
efficiently.
Here's an example:
class base {
public:
base (string &const1, string @const2) {s1 = const1; s2 = const2;}
private:
string s1, s2;
};
class kid1 : public base {
public:
kid1 () {base ("Child 1", "Table 1");}
};
class kid2 : public base {
public:
kid2 () {base ("Child 2", "Table 2");}
};
My problem is that each object has all the constants as variables.
Is there any way to improve the efficiency?
Thanks a lot in advance,
Omer.
I have two classes that have the same functionality, but with
different constants, e.g. database table name.
I've defined a base class that gets the constants in the constructor,
and maintain the functionality. It works fine, but not very
efficiently.
Here's an example:
class base {
public:
base (string &const1, string @const2) {s1 = const1; s2 = const2;}
private:
string s1, s2;
};
class kid1 : public base {
public:
kid1 () {base ("Child 1", "Table 1");}
};
class kid2 : public base {
public:
kid2 () {base ("Child 2", "Table 2");}
};
My problem is that each object has all the constants as variables.
Is there any way to improve the efficiency?
Thanks a lot in advance,
Omer.