mardi 9 juillet 2019

How to declare a C++ vector? [on hold]

I am having a difficult time understanding the errors I am receiving when declaring vectors with a fixed size. I tried declaring them different ways but receive errors each time.

The errors are:

error: unknown type name 'oriValues'
error: expected member name or ';' after declaration specifiers

and,

error: unknown type name 'arrayNum'

And the code is:

#ifndef FANCYSTEPCOUNTER_H
#define FANCYSTEPCOUNTER_H

#include <vector>

class FancyStepCounter
{
private:

    std::vector<float> oriValues;
    oriValues.reserve(3);                           // ERROR
    bool isUp {false};
    int continueUpCount {0};
    int lastContinueUpCount {0};
    float peakValue {0};
    float valleyValue {0};
    long timeOfThisPeak {0};
    float lastSensorValue {0};
    float lastFilteredSensorValue {0};
    float thresholdValue {0.6};
    const float judgeValue {1.5};
    const int arrayNum {4};
    std::vector<float> thresholdArray(arrayNum);    // ERROR
    int arrayCount {0};
    int totalCount {0};

public:
    FancyStepCounter();
    ~FancyStepCounter();

    float averageValue(std::vector<float> value, int n);
    float calculateThreshold(float value);
    bool detectPeak(float newValue, float oldValue);
    void detectNewStep(float sensorValue);
};

#endif // FANCYSTEPCOUNTER_H

Aucun commentaire:

Enregistrer un commentaire