Версия для печати темы
Нажмите сюда для просмотра этой темы в оригинальном формате
Форум программистов > C/C++: Общие вопросы > Cpp Visual Studio Code Platformio


Автор: Ripperr 5.5.2019, 18:35
Код

#include <Arduino.h>
#include <WiFi.h>
#include <FreeRTOS.h>
#include <Tone32.h>
#include <analogWrite.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#include <vector>

using namespace std;
vector<float> templist;
templist.push_back(1);


'templist' does not name a type
this declaration has no storage class or type specifier

не фурычит данная конструкция ...
к обявленю у компилятора вопросов нет  vector<float> templist;
а вот дальше немогу работать с вектором ...  

Автор: Romikgy 5.5.2019, 21:37
Код

templist.push_back(1.0);

Автор: Ripperr 5.5.2019, 22:43
обращаться к переменной можно только внутри функций или классов ... а я патался сразу после декларации ..

Код

GetTemp()
  {
    sensors.begin();
    //temp60.reserve(60);
  }
  public:
    float gettemp(DeviceAddress deviceAddress)
    {    
      sensors.requestTemperatures();
      temperature = sensors.getTempC(deviceAddress);
        if(temp60.size() == 15)
        {
          temp60.erase(temp60.begin());
        }
      temp60.push_back(temperature);
      return temperature;
    }
  public:
    float temp15diff()
    {
    float min, max = 0;
      if (!temp60.empty())
      {
        for(int i = 0;  i<= temp60.size()-1; i++)
        {
          if(i == 0){ min = temp60[i]; max = temp60[i];}
          if(temp60[i] < min) min= temp60[i];
          if(temp60[i] > max) max= temp60[i];
        }
      }
    return(max - min);
    }
 

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)