Can I implement a nested class which uses an externally-defined class?
class Bank {
public:
int encoderPos; // active position of encoder
class ClickButton button; // Button Control object (externally defined)
// (This is *supposed* to be a
// forward-declaration kind of thing)
Bank(int encoderPin)
: button(encoderPin), // attempt to create button object calling
// constructor for ClickButton class
encoderPos(0){
}
};
This yields an error, of course:
In constructor 'Bank::Bank(int)':
warning: 'Bank::button' will be initialized after [-Wreorder]
I would expect/want the constructor for button to be called before the constructor for bank.
Aucun commentaire:
Enregistrer un commentaire