In the class CSensorGrid, implement the method print (tSensorType), which outputs the sensor type as well as the minimum, maximum and average temperatures for (3) all sensors of a certain sensor type of the sensor network. The parameter value determines from which sensor type the objects are displayed.
If you need implementation access to the CTempSensor :: m_SensorType attribute, implement the get method.
The output format should look like in the example below; Use a suitable method or function of the CTempSensor class for the display.
https://www.pic-upload.de/view-35223573/Bildschirmfoto2018-04-25um12.02.26.png.html
I tried the task but to much errors?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
|
/*
* CSensorGrid.cpp
*
* Created on: 23.04.2018
* Author: macbook
*/
#include "CSensorGrid.h"
CSensorGrid::CSensorGrid(int maxSensorIdx) {
if(m_maxSensorIdx >= 5 ){
m_maxSensorIdx = maxSensorIdx;
}
else{
m_maxSensorIdx = 10;
}
m_pSensor = new CTempSensor [m_maxSensorIdx];
}
CSensorGrid::~CSensorGrid() {
delete[] m_pSensor;
}
void CSensorGrid::operator += (const CTempSensor&rop){
if(m_nextSensorIdx >= m_maxSensorIdx){
CTempSensor* sensor_temp= new CTempSensor[m_maxSensorIdx+5];
for(int i = 0; i<m_maxSensorIdx; i++){
sensor_temp[i] = m_pSensor[i];
}
delete[] m_pSensor;
m_pSensor= sensor_temp;
}
m_pSensor[m_nextSensorIdx++] = rop;
}
void CSensorGrid::print(tSensorType type){
if(type == GENERAL){
cout << "Typ:" << type << "min:" << CTempSensor::m_minTemp << ""<< "max:" << CTempSensor::m_maxTemp << ""<< "Durschnit::" << CTempSensor::calculateMeanTemp() << endl;
}
}
|
Description Resource Path Location Type
'm_maxTemp' is a private member of 'CTempSensor' CSensorGrid.cpp /CTemp line 50 C/C++ Problem
'm_minTemp' is a private member of 'CTempSensor' CSensorGrid.cpp /CTemp line 50 C/C++ Problem
call to non-static member function without an object argument CSensorGrid.cpp /CTemp line 50 C/C++ Problem
Invalid arguments '
Candidates are:
double calculateMeanTemp()
' CSensorGrid.cpp /CTemp line 50 Semantic Error
Invalid overload of 'endl' CSensorGrid.cpp /CTemp line 50 Semantic Error
invalid use of non-static data member 'm_maxTemp' CSensorGrid.cpp /CTemp line 50 C/C++ Problem
invalid use of non-static data member 'm_minTemp' CSensorGrid.cpp /CTemp line 50 C/C++ Problem
make: *** [CSensorGrid.o] Error 1 CTemp C/C++ Problem
in-class initialization of non-static data member is a C++11 extension [-Wc++11-extensions] CSensorGrid.h /CTemp line 20 C/C++ Problem
declared private here CTempSensor.h /CTemp line 23 C/C++ Problem
declared private here CTempSensor.h /CTemp line 24 C/C++ Problem
Please help