Class Constructor Error

ERROR:

no matching function to call 'Buttons::Buttons()'

CODE:

#include "SimonPlayer.h"
#include "Pitches.h"

SimonPlayer::SimonPlayer(int _redLED, int _grnLED, int _yelLED, int _bluLED,
                         int _redBut, int _grnBut, int _yelBut, int _bluBut,
                         int _speaker, bool _debugMode){

  redLED = _redLED;
  grnLED = _grnLED;
  yelLED = _yelLED;
  bluLED = _bluLED;
  redBut = _redBut;
  grnBut = _grnBut;
  yelBut = _yelBut;
  bluBut = _bluBut;
  speaker = _speaker;
  debugMode = _debugMode;
  unsigned long bounceBuffer = 20;
  playerButtons = new Buttons(redBut, grnBut, yelBut, bluBut,
                              redLED, grnLED, yelLED, bluLED, bounceBuffer);
  
  pinMode(speaker, OUTPUT);
}

Am I creating the Buttons-type object "playerButtons" wrong?

What’s your .h. look like?

BTW, pinMode in a constructor probably won’t work right if the object is global. That constructor may get called before init() does and the hardware won’t be set up yet. Constructors are for setting up variables. Hardware stuff belongs in a begin() or init() method that can be called from setup once the hardware is ready.

HEADER FILE:

#include "ColorSequence.h"
#include "Buttons.h"

class SimonPlayer {

  private:
  
    int redLED;
    int grnLED;
    int yelLED;
    int bluLED;
    int redBut;
    int grnBut;
    int yelBut;
    int bluBut;
    int speaker;
    bool debugMode;
    Buttons playerButtons;

  public:

    /* Creates a SimonPlayer object.
     *  
     * Parameters: int _redLED - pin number for the red LED
     *             int _grnLED - pin number for the green LED
     *             int _yelLED - pin number for the yellow LED
     *             int _bluLED - pin number for the blue LED
     *             int _redBut - pin number for the red button
     *             int _grnBut - pin number for the green button
     *             int _yelBut - pin number for the yellow button
     *             int _bluBut - pin number for the blue button
     *             int _speaker - pin number for the piezo element
     *             bool _debugMode - indication of whether to print status info
     */
    SimonPlayer(int _redLED, int _grnLED, int _yelLED, int _bluLED,
                int _redBut, int _grnBut, int _yelBut, int _bluBut,
                int _speaker, bool _debugMode);


    /* Reads in player inputs in response to SimonGame.
     * 
     * Parameters: ColorSequence& responses - reference to the sequence of player responses
     *             int count - the number of button presses
     *  
     */
    void getResponses(ColorSequence& response, int count);
};
SimonPlayer::SimonPlayer(_redLED, _grnLED, _yelLED, _bluLED,
                         _redBut, _grnBut, _yelBut, _bluBut,
                         _speaker, _debugMode){

Datatype ... space ... symbol name. Where are the datatypes?

Oh sheesh! Does it show that I've spent 8 hours on this program today?

Thanks!

Now I'm getting a different error in the same constructor:

no matching function to call 'Buttons::Buttons()'

Buttons class source:

#include "Buttons.h"


Buttons::Buttons(int _pinA, int _pinB, int _pinC, int _pinD,
                 int _ledA, int _ledB, int _ledC, int _ledD,
                 unsigned long _bounceDelay){
  
  pinA = _pinA;
  pinB = _pinB;
  pinC = _pinC;
  pinD = _pinD;
  ledA = _ledA;
  ledB = _ledB;
  ledC = _ledC;
  ledD = _ledD;
  bounceDelay = _bounceDelay;
  buttonStateA = HIGH;
  buttonStateB = HIGH;
  buttonStateC = HIGH;
  buttonStateD = HIGH;
  lastStateA = HIGH;
  lastStateB = HIGH;
  lastStateC = HIGH;
  lastStateD = HIGH;
  
  pinMode(pinA, INPUT);
  pinMode(pinB, INPUT);
  pinMode(pinC, INPUT);
  pinMode(pinD, INPUT);
  pinMode(ledA, OUTPUT);
  pinMode(ledB, OUTPUT);
  pinMode(ledC, OUTPUT);
  pinMode(ledD, OUTPUT);
}

The error makes it look like you’ve tried to use that constructor with no arguments. Which is weird because the compiler should create a no argument constructor for you if you don’t I thought.

As always, post the whole code. The error often isn’t where you think it is. And here it obviously isn’t in the constructor that doesn’t have any line in it that could create that error.

NVM, I see it up there.

This line in your other constructor calls a no argument constructor for buttons.

Buttons playerButtons;

to create the object since you didn’t pass any parameters. So does the Buttons class have a no argument constructor?

Can someone else clear up my confusion on when you get a free one and when you don’t?

Maybe you could ask this guy...
https://stackoverflow.com/questions/47707860/arduino-class-constructor

Seriously though, if you're going to sprinkle the same question all over the internet, at least have a little consideration and give links between them so nobody ends up wasting effort giving you answers you already have. And do note, it's mostly the same people, so it's not like you're really polling two audiences there.