2016-06-16 1 views
0

私はarduino用のRFモジュールのための図書館を作っています。私は、私が解決する方法がわからないというエラーが1つあるとき、私のコードでほぼ完了しています。 エラーコードのこの部分で起こる:'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を使用することができますように、私の先生はarduinoの、そのかなり標準で動作するようになったlibaryです。私はあなたに十分な情報があることを祈っています 多分これで私を助けることができる。

答えて

0
class whatsapp : public send, public receive 

あなたは多重継承を使用している、との両方がsend_byteの実装、したがって、エラーを持っているでしょう。

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

これは悪いデザインのようです:

関連する問題