Help with C++ Pointers and Arrays for a Library

Hi, Im making a Library, that will debounce buttons, and so, I have the code running flawlessly, now the thing is that I want to learn to write Libraries as well, but Im having a bad time with pointers and arrays.

This is my header file:

#ifndef Pulsadores_h
#define Pulsadores_h

#include "Arduino.h"

class Pulsadores
    void HelloWorld(void);
    bool Read(long);
    byte* _BM;      //Button Mode
    byte BM;
    int* _PA;       //Pin Array

    byte _NB;       //Number of Buttons
    long _LT;
    long _DT;


And this is my .CPP file

#include "Arduino.h"

#include "Pulsadores.h"

Pulsadores::Pulsadores(byte NB, int *PinArray)
    int i = -1;
    _NB = NB;
    _PA = PinArray;

    _DT = 25000;
        *(_BM + i) = 0;

void Pulsadores::HelloWorld(void)
    int i = 0;
    Serial.println("Hello World");
        Serial.print("Button ");
        Serial.print(", Pin: ");
        Serial.print(" Mode: ");


bool Pulsadores::Read(long CT)
    if( (CT-_LT) > _DT )
        _LT = CT;

And This is My Arduino Code:

#include <Pulsadores.h>

int PinArray[8] = {53, 51, 49, 47, 45, 43, 41, 39};
  Pulsadores A = Pulsadores(8,PinArray);
void setup() {


void loop() {

The thing is that when I run it I get this on the serial monitor:

Hello World
Button 1, Pin: 53 Mode: 37.
Button 2, Pin: 51 Mode: 0.
Button 3, Pin: 49 Mode: 0.
Button 4, Pin: 47 Mode: 0.
Button 5, Pin: 45 Mode: 120.
Button 6, Pin: 43 Mode: 98.
Button 7, Pin: 41 Mode: 193.
Button 8, Pin: 39 Mode: 82.

When I should be getting “Mode 0” for all.
I think this is a really nooby question, but i have no clue what I am doing wrong, thanks!

And where do you initialize _BM to actually point to anything?

Ray L.

Please post code using code tags. Edit your posts, before the code type
** **[code]** **
and after the code type
** **[/code]** **
. It's easier to read, preserves indentations and prevents italics.

OK, Great, so I changed the pointer to an array on the header file

byte _BM; //Button Mode

So, you created a 0 element array, and set all 8 elements to 0, and you can't understand what went wrong. Hmmm.