2016-06-16 2 views
0

나는 arduino 용 RF 모듈 용 라이브러리를 만들고 있습니다. 나는 내가 어떻게 해결 해야할지 모르는 오류가 하나있을 때 거의 내 코드로 끝난다. 오류 코드의이 작품에서 일어나는 :'send_byte'에 대한 참조가 모호합니다.

#include "Rf_module.hpp" 

class send; 
class receive; 

class whatsapp : public send, public receive 
{ 
private: 
    hwlib::target::pin_in_out &whatsapp_pin; 
public: 
    whatsapp(hwlib::target::pin_in_out &whatsapp_pin, int frequency): 
     send (whatsapp_pin, frequency), 
     receive (whatsapp_pin, frequency), 
     whatsapp_pin(whatsapp_pin) 
    {} 

    void send_text(char text[], int length) 
    { 
     for(int i = 0; i< length-1; i++) 
     { 
      int ascii_value = text[i]; 
      send_byte(ascii_value); 

오류는 다음과 같습니다 'send_byte'에 대한 참조를 모호합니다. 내 코드는 부분적으로 추상 클래스 통신으로 시작하는 몇 가지 클래스의 구조입니다.

#include "hwlib.hpp" 

class communication 
{ 
protected: 
    hwlib::target::pin_in_out & current_pin; 
    int sending_frequency; 
public: 
    communication(hwlib::target::pin_in_out & current_pin, int sending_frequency); 
    virtual void send_bit(int bit); 
    virtual int get_bit(); 
virtual void get_startbit() = 0; 
virtual void send_startbit() = 0; 
virtual int get_byte() = 0; 
virtual void send_byte(int byte) = 0; 
}; 

또한 RF 모듈 자체에 대한 송수신 클래스가 있습니다.

#include "hwlib.hpp" 
#include "communication.hpp" 


class send : public communication 
{ 
public: 
    send(hwlib::target::pin_in_out & current_pin, int sending_frequency); 
    void send_startbit() override; 
    void send_byte(int byte) override; 
    void test_send(); 

class receive : public communication 
{ 
public: 
    receive(hwlib::target::pin_in_out & current_pin, int sending_frequency); 
    void get_startbit() override; 
    int get_byte() override; 
    void test_receive(); 
}; 

내 주요 모양은 다음과 같습니다.

#include "hwlib.hpp" 
#include "whatsapp.hpp" 

int main(void) 
{ 
    auto pin = hwlib::target::pin_in_out(1,17); 
    pin.direction_set_output(); 

    whatsapp sender(pin,10); 
    sender.test_send(); 


    return 0; 
} 

파일을 많이 포함되어있는 hwlib의 libary 내 교사가 아두 이노, 당신이 핀과 몇 가지 다른 freatures을 사용할 수 있습니다 점에서 그것의 꽤 표준 작업을 준 libary이다. 나는 너희들이 충분한 정보를 가지고 있기를 바란다. 아마 이것으로 나를 도울 수있을 것이다.

답변

0
class whatsapp : public send, public receive 

여러 상속을 사용하고 모두 send_byte의 구현 및 따라서 오류가있을 것입니다. 어떤 수업을 통해 지정해야합니까 :

void send_text(char text[], int length) 
{ 
    ... 
      send::send_byte(ascii_value); 

그러나 이것은 나쁜 설계 인 것 같습니다!

관련 문제