0
기본적으로 외부 클래스를 초기화하여 모든 메서드에서 멤버로 사용하려고합니다.외부 클래스의 멤버 만들기
내가 시도하는 것 :
- 헤더 파일의 멤버를 초기화 (오류 :
error: 'RECV_PIN_1' is not a type
) - 은 (지금은 내 방법에서 사용할 수없는) 생성자에 초기화
여기를 내 단축 코드 :
// Receiver.h
#include "Arduino.h"
#include "IRremote.h"
class Receiver {
public:
Receiver();
void tick();
private:
static const int LED_PIN = 13;
static const int RECV_PIN_1 = 11;
static const int MAX_HEALTH = 1000;
// [..]
IRrecv irrecv(RECV_PIN_1); // this does not work
// [..]
};
// Receiver.cpp
#include "Arduino.h"
#include "IRremote.h"
#include "Receiver.h"
Receiver::Receiver() {
// [..]
}
void Receiver::tick() {
checkHitIndicator();
// if there is a result
if (irrecv.decode(&results)) {
playerHitDetected(10);
// receive the next value
irrecv.resume();
}
}
somebod 어떻게 그리고 왜 그것을 성취 할 수 있는지 설명 할 수 있습니다.
안녕하세요, 첫 번째 방법은 내 컴파일러에서 지원되지 않습니다. 두 번째 것은 'IRrecv :: IRrecv (int)'에 대한 정의되지 않은 참조를 던졌습니다. –
@ JulianHollmann : 두 번째는 그 새벽부터 표준이었습니다. –
내 의견을 업데이트했으며 두 번째 방법은 저에게 맞지 않습니다 –