"undefined reference" in the constructor of a C ++ function

2

I am creating a class of name VS1838B that is composed of other instances.

This is the class header:

#ifndef INFRAREDRECEIVERVS1838B_H
#define INFRAREDRECEIVERVS1838B_H

#include "Arduino.h"
#include "IRremote.h"
#include "IRremoteInt.h"

class VS1838B{

public:
    //Construtor
    VS1838B(int pinoReceptorIR);

    //Atributos
    IRrecv _receptorIR;                   //Objeto do tipo IRrecv
    decode_results _bufferSinalRecebido;  //Objeto que armazena o sinal recebido
    int _pinoInput;

};


#endif  /* INFRAREDRECEIVERVS1838B_H */

This is the .cpp file

#include "Arduino.h"
#include "InfraRedReceiverVs1838b.h"
#include "IRremote.h"
#include "IRremoteInt.h"


//Construtor
VS1838B::VS1838B(int pinoReceptorIR)
:_receptorIR (pinoReceptorIR), _bufferSinalRecebido()
{
_pinoInput = 11;
}

I get the following error message when trying to instantiate the class.

InfraRedReceiverVs1838b.cpp: 9: undefined reference to 'IRrecv :: IRrecv (int)'

This is the header of the class which has not been found reference:

// main class for receiving IR
class IRrecv
{
public:
  IRrecv(int recvpin);
  void blink13(int blinkflag);
  int decode(decode_results *results);
  void enableIRIn();
  void resume();
private:
  // These are called by decode
  int getRClevel(decode_results *results, int *offset, int *used, int t1);
  long decodeNEC(decode_results *results);
  long decodeSony(decode_results *results);
  long decodeSanyo(decode_results *results);
  long decodeMitsubishi(decode_results *results);
  long decodeRC5(decode_results *results);
  long decodeRC6(decode_results *results);
  long decodePanasonic(decode_results *results);
  long decodeLG(decode_results *results);
  long decodeJVC(decode_results *results);
  long decodeSAMSUNG(decode_results *results);
  long decodeHash(decode_results *results);
  int compare(unsigned int oldval, unsigned int newval);

} 
;

Why the error message? How can I construct a class that has instance attributes of other classes? I am a beginner and any help and welcome.

    
asked by anonymous 28.07.2015 / 05:37

1 answer

-1

Try using:

In class definition states:

IRrecv* _receptorIR;                   //Objeto do tipo IRrecv
decode_results* _bufferSinalRecebido;  //Objeto que armazena o sinal recebido

And put the constructor like this:

//Construtor
VS1838B::VS1838B(int pinoReceptorIR)
{
    _pinoInput = 11;
    _receptorIR = new IRrecv(pinoReceptorIR);
    _bufferSinalRecebido = new decode_results();
}

Do not forget to create the destructor and release the memories.

    
30.11.2015 / 16:33