ライブラリ機能を複数のクラスに分割するのはこれが初めてです。クラスごとにオブジェクトをインスタンス化する方法が正確にはわかりません。クラスが同じ.hファイルにある場合でも、それらのクラスメソッドと変数にアクセスするために、クラスオブジェクトをインスタンス化する必要がありますか?30行目で「不完全なタイプは許可されていません」というエラーが表示されます。
私のコード:
/*
File: sensor.h
Header file for phSensor Library.
*/
#ifndef SENSOR_H
#define SENSOR_H
#include "mbed.h"
#include "cfExtensions.h"
#include "msExtensions.h"
#include <string>
class phSensor;
class ecSensor;
class tempSensor;
class sensor
{
public:
sensor(); //Default sensor constructor
sensor(cfExtensions &cfExt, msExtensions &msExt);
private:
cfExtensions &_cfExt;
msExtensions &_msExt;
phSensor ph; // Line 30, gets error "incomplete type is not allowed"
ecSensor ec;
tempSensor temp;
string _phCurrentPhValue;
string _phMaxValue;
string _phMinValue;
};
class phSensor
: public sensor
{
public:
phSensor();
void outputPhMaxValue();
private:
float _getCurrentPhValue();
float _getPhMaxValue();
float _getPhMinValue();
void _setPhMaxValue();
void _setPhMinValue();
void _calibratePhSensor();
Ticker getPhMax;
Ticker getPhMin;
};
class ecSensor
: public sensor
{
public:
ecSensor();
};
class tempSensor
: public sensor
{
public:
tempSensor();
};
#endif