no default constructor!! But i dont need one..

07 Aug 2011

Hello,

i'm trying to understand C++ in a better way and i am stuck here..

i was writing a class to interface LEDs on the mbed

// the Header file

class myLEDS{
public:
     myLEDS(PinName);
     myLEDS(PinName, PinName);
protected:
     DigitalOut _a;
     DigitalOut _b;
}

// the C++ file

myLEDS::myLEDS(PinName a): _a(a){        // error here

}


myLEDS::myLEDS(PinName a, PinName b): _a(a), _b(b){

}

I am getting an error "no default constructor exists for "mbed::DigitalOut" in the C++ file.. how do i get rid of that??

thanks...

07 Aug 2011

You have to initialize _b with something. If you don't need an actual pin, use NC.

07 Aug 2011

Igor, Thanks :)

21 Nov 2012

I'm having a similar issue, how exactly was this fixed?

21 Nov 2012

Well in my case I had to initialize pin b with something...

so..

the C++ file

myLEDS::myLEDS(PinName a): _a(a), _b(NC){ works

}