Creating a Library Help?

I’m making a library to make my life easier, but I have very little experience in making libraries. Does anyone know why this won’t work or fix it?

BombDisplay.h:

#ifndef BombDisplay_H
#define BombDisplay_H

#include <Arduino.h>

class BombDisplay {
public:
	BombDisplay();
	~BombDisplay();
	void displayOne(int numberone);
	void displayTwo(int numbertwo);
	void setRegisterPin();
	void clearRegisters();
	void writeRegisters();
};

#endif

BombDisplay.cpp:

#include "BombDisplay.h"
#define number_of_74hc595s 2
#define numOfRegisterPins number_of_74hc595s * 8
boolean registers[numOfRegisterPins];
const byte SER_Pin = 9;
const byte RCLK_Pin = 10;
const byte SRCLK_Pin = 12;

BombDisplay::BombDisplay(){
	pinMode(SER_Pin, OUTPUT);
	pinMode(RCLK_Pin, OUTPUT);
	pinMode(SRCLK_Pin, OUTPUT);
	pinMode(11, OUTPUT);
	pinMode(13, INPUT);
}

BombDisplay::~BombDisplay(){
}

void BombDisplay::displayOne(int numberone){
	if(numberone == 1){
		setRegisterPin(2, HIGH);
		setRegisterPin(3, HIGH);
	}
	if(numberone == 2){
		setRegisterPin(1, HIGH);
		setRegisterPin(7, HIGH);
		setRegisterPin(6, HIGH);
		setRegisterPin(3, HIGH);
		setRegisterPin(4, HIGH);
	}
}

void BombDisplay::displayTwo(int numbertwo){
}

void clearRegisters(){
	for(int i = numOfRegisterPins - 1; i >=  0; i--){
		registers[i] = LOW;
	}
}

void writeRegisters(){
	digitalWrite(RCLK_Pin, LOW);

	for(int i = numOfRegisterPins - 1; i >=  0; i--){
		digitalWrite(SRCLK_Pin, LOW);

		int val = registers[i];

		digitalWrite(SER_Pin, val);
		digitalWrite(SRCLK_Pin, HIGH);

	}
	digitalWrite(RCLK_Pin, HIGH);
}

void setRegisterPin(int index, int value){
	registers[index] = value;
}

Here’s the error:

C:\Users\Mitch\Desktop\arduino-1.0.1\libraries\BombDisplay\BombDisplay.cpp: In member function ‘void BombDisplay::displayOne(int)’:
C:\Users\Mitch\Desktop\arduino-1.0.1\libraries\BombDisplay\BombDisplay.cpp:22: error: no matching function for call to ‘BombDisplay::setRegisterPin(int, int)’
C:\Users\Mitch\Desktop\arduino-1.0.1\libraries\BombDisplay/BombDisplay.h:13: note: candidates are: void BombDisplay::setRegisterPin()
C:\Users\Mitch\Desktop\arduino-1.0.1\libraries\BombDisplay\BombDisplay.cpp:23: error: no matching function for call to ‘BombDisplay::setRegisterPin(int, int)’
C:\Users\Mitch\Desktop\arduino-1.0.1\libraries\BombDisplay/BombDisplay.h:13: note: candidates are: void BombDisplay::setRegisterPin()
C:\Users\Mitch\Desktop\arduino-1.0.1\libraries\BombDisplay\BombDisplay.cpp:26: error: no matching function for call to ‘BombDisplay::setRegisterPin(int, int)’
C:\Users\Mitch\Desktop\arduino-1.0.1\libraries\BombDisplay/BombDisplay.h:13: note: candidates are: void BombDisplay::setRegisterPin()
C:\Users\Mitch\Desktop\arduino-1.0.1\libraries\BombDisplay\BombDisplay.cpp:27: error: no matching function for call to ‘BombDisplay::setRegisterPin(int, int)’
C:\Users\Mitch\Desktop\arduino-1.0.1\libraries\BombDisplay/BombDisplay.h:13: note: candidates are: void BombDisplay::setRegisterPin()
C:\Users\Mitch\Desktop\arduino-1.0.1\libraries\BombDisplay\BombDisplay.cpp:28: error: no matching function for call to ‘BombDisplay::setRegisterPin(int, int)’
C:\Users\Mitch\Desktop\arduino-1.0.1\libraries\BombDisplay/BombDisplay.h:13: note: candidates are: void BombDisplay::setRegisterPin()
C:\Users\Mitch\Desktop\arduino-1.0.1\libraries\BombDisplay\BombDisplay.cpp:29: error: no matching function for call to ‘BombDisplay::setRegisterPin(int, int)’
C:\Users\Mitch\Desktop\arduino-1.0.1\libraries\BombDisplay/BombDisplay.h:13: note: candidates are: void BombDisplay::setRegisterPin()
C:\Users\Mitch\Desktop\arduino-1.0.1\libraries\BombDisplay\BombDisplay.cpp:30: error: no matching function for call to ‘BombDisplay::setRegisterPin(int, int)’
C:\Users\Mitch\Desktop\arduino-1.0.1\libraries\BombDisplay/BombDisplay.h:13: note: candidates are: void BombDisplay::setRegisterPin()

Can anyone see what’s wrong?

Inside the BombDisplay object you declare a function called setRegisterPin but you don't define the BombDisplay::setRegisterPin() function. You define a global "setRegisterPin" function but that's not the same as the one declared in BombDisplay.

How can I fix this, because I have very little experience in C++

Try defining the global function before you use it, and not after. Or, provide a forward declaration to it at the top of your file.

Your header and cpp file define the "setRegisterPin" function differently. In the header it takes no variables [setRegisterPin()] whereas in the cpp file it takes two [setRegisterPin(int index, int value)].

Try this:

class BombDisplay {
public:
     BombDisplay();
     ~BombDisplay();
     void displayOne(int numberone);
     void displayTwo(int numbertwo);
     void setRegisterPin(int,int);
     void clearRegisters();
     void writeRegisters();
};

Code seems to compile correctly... Will test if works.

Why are the clearRegisters(), setRegisterPin(), and writeRegisters() methods defined as class methods, but not implemented as class methods (using the BombDisplay:: in front of the names?