I believe I'm thinking about this "badly" (non-C++'y). Here's what I'm trying to do
class AA {
public:
AA(const char* name, unsigned short number);
int Write(int x);
...
}
class BB: public AA {
public:
BB(const char* name, unsigned short number, const char* other);
BB(AA aaObj, const char* other);
int Write(double y, int x) {
/* do something */
AA::Write(x)
}
...
}
On the second BB constructor I'd like to replace the base object of BB with aaObj. I don't want a copy, I want the actual base object to the be same (same reference).
Questions:
- Is this possible?
- Is this a bad idea?
- Is there a better pattern for this (factory producing objects with shared members?