#ifndef BN_h
#define BN_h
#pragma once
#include "Arduino.h"
class BN {
// bool BlockNot::resetTimer;
public:
BN(int a = 1, int b = 2);
bool hasPassed(int c = 0);
private:
int aNumber;
};
#endif
#include <Arduino.h>
#include <BN.h>
BN::BN(int a, int b)
{
//Various code
}
bool BN::hasPassed(int c) {
return aNumber == c;
}
I would like to be able to call the hasPassed function using different names (for code readability). I went through different articles on function pointers but I can't seem to get any of the examples to work inside a library.
Does anyone know how to properly create function pointers inside a library?
Delta_G:
All it's doing is a text based find and replace, so be careful how you use this stuff. But as long as you're just substituting one name for another it should work.
How does that translate to #define(ing) a function that has arguments that need to get passed into it and then make decisions based on those arguments? Are you saying something like this should work in my libraries .cpp file?
#include <Arduino.h>
#include <BN.h>
#define isDone BN::hasPassed
BN::BN(int a, int b)
{
//Various code
}
bool BN::hasPassed(int c) {
aNumber = c;
}
so that once the library is instantiated, I can just use the name given in the #define statement, like this?