I’m new to C++ and I have a problem with classes.
I got this prototype
class MMA7455 : public Accel
{
public:
MMA7455(uint8_t);
uint8_t accel_get_data(acceleration_t*);
private:
uint8_t accel_data_ready(void);
};
and I want to create an instance of it
MMA7455 accel = MMA7455(0x21);
but the following message appears
In function `global constructors keyed to accel':
sensors.cpp:(.text+0x8): undefined reference to `MMA7455::MMA7455(unsigned char)'
Why it’s looking for ‘unsigned char’ argument? Same message even if I try to implicitly cast the type of constant
MMA7455 accel = MMA7455((uint8_t)0x21);
You probably didn’t link your .cpp file containing the constructor definition. “uint8_t” is a typedef for ‘unsigned char”.