I have tried to implement the C++11 feature (I've used this answer as a reference Can I call a constructor from another constructor (do constructor chaining) in C++?). Obviously, I've done it wrong but I don't understand why.
I get several warnings in the following piece of code:
- Member
_output
was not initialized in this constructor - Member
_protocol_scanner
was not initialized in this constructor - Member
_state
was not initialized in this constructor - Member
_source
was not initialized in this constructor
This is the code:
class UartScanner {
public:
UartScanner(periph::IStreamDevice *source, periph::IStreamDevice *output);
UartScanner(periph::IStreamDevice *source);
~UartScanner();
private:
typedef enum
{
WAITING_SYNC,
WAITING_UBLOX_MSG,
WAITING_NOVATEL_MSG
} states_t;
periph::IStreamDevice *_source;
periph::IStreamDevice *_output;
ProtocolScanner *_protocol_scanner;
states_t _state;
};
UartScanner::UartScanner(periph::IStreamDevice *source, IStreamDevice *output):
_source(source),
_output(output),
_state(WAITING_SYNC)
{
_protocol_scanner = new ProtocolScanner(source,output);
}
UartScanner::UartScanner(periph::IStreamDevice *source): UartScanner(source,0)
{
}
class IStreamDevice {
public:
virtual ~IStreamDevice() {}
virtual uint32_t read(uint8_t* data, uint32_t size) = 0;
virtual uint32_t write(const uint8_t* data, uint32_t size) = 0;
};