Using external class in constructor: no matching function for call error

I’m try to create a custom class for some buttons that will all have the same set of properties and methods. I want to use the Bounce library to denounce those buttons. In my constructor I am trying to create a Bounce object. Is there a way to do this or should this be handled outside of my class?

I’m not clear if I’m missing something regarding how types are handled or if missing a higher level concept of the proper approach to this.

The error I get is:

BounceButton.cpp: In constructor 'BounceButton::BounceButton(int)':
BounceButton.cpp:5: error: no matching function for call to 'Bounce::Bounce()'
BounceButton.cpp:5:38: note: candidates are:
In file included from BounceButton.cpp:2:0:
/Applications/ note: Bounce::Bounce(uint8_t, long unsigned int)
/Applications/ note:   candidate expects 2 arguments, 0 provided
/Applications/ note: constexpr Bounce::Bounce(const Bounce&)
/Applications/ note:   candidate expects 1 argument, 0 provided
/Applications/ note: constexpr Bounce::Bounce(Bounce&&)
/Applications/ note:   candidate expects 1 argument, 0 provided


#ifndef BounceButton_h
#define BounceButton_h

#include "Arduino.h"

class BounceButton {
    BounceButton(int btnPin);
    Bounce _btn;



#include "Arduino.h"
#include "Bounce.h"
#include "BounceButton.h"

BounceButton::BounceButton(int btnPin) {
  _btn = Bounce(btnPin, 100);

example .ino:

#include <Bounce.h>
#include "BounceButton.h"

void setup() { }
void loop() { }

Change your constructor (in example.cpp) to be:

BounceButton::BounceButton(int btnPin) : _btn (btnPin, 100) { }

Thank you! I was actually just returning to share that after rereading documentation about initialization lists and finding a few other examples other their usage I was able to work this out. I didn't quite understand how they were working previously so didn't properly apply them to my example.

Thanks again for the reply.