Kind of not understanding how classes work. Particularly when an instance of the class is created.
I am new to C++ but I have programming in C for a few years.
Based on the book that I am learning c++ from in a constructor anything past the : is a parameter list.
I2SMEMSSampler is a derived class of I2SSampler. I pass 3 params to I2SMEMSSampler but the parameter list only accepts two parameters (in cpp file)
Can someone tell me what is going on when an object of class I2SMEMSSampler is created from main.cpp ?
Here is the code in question.
In main.cpp I have this line:
Code:
I2SSampler *input = new I2SMEMSSampler(I2S_NUM_0, i2s_mic_pins, i2s_mic_Config);
which is declared in an h file like this:
Code:
class I2SMEMSSampler : public I2SSampler
{
private:
i2s_pin_config_t m_i2sPins;
bool m_fixSPH0645;
protected:
void configureI2S();
public:
I2SMEMSSampler(
i2s_port_t i2s_port,
i2s_pin_config_t &i2s_pins,
i2s_config_t i2s_config,
bool fixSPH0645 = false);
virtual int read(int16_t *samples, int count);
};
in the cpp file it is defined like this, I don't understand the significance of what comes after the colon because when i create an object of the class I am giving the constructor 3 parameters as shown above in main.cpp;
Code:
I2SMEMSSampler::I2SMEMSSampler(
i2s_port_t i2s_port,
i2s_pin_config_t &i2s_pins,
i2s_config_t i2s_config,
bool fixSPH0645) : I2SSampler(i2s_port, i2s_config)
{
m_i2sPins = i2s_pins;
m_fixSPH0645 = fixSPH0645;
}