user39817: Below code was working fine without using classes, after using class an error pops up: esp8266 is not defined in this scope
#include<SoftwareSerial.h>
#include<ArduinoJson.h>
#include<Wire.h>
#include<LCD.h>
#include<LiquidCrystal_I2C.h>
#include<SPI.h>

#define DEBUG true
// Housekeeping stuff for LCD display
#define I2C_ADDR    0x3F
#define BACKLIGHT_PIN     3
#define En_pin  2
#define Rw_pin  1
#define Rs_pin  0
#define D4_pin  4
#define D5_pin  5
#define D6_pin  6
#define D7_pin  7
LiquidCrystal_I2C
lcd(I2C_ADDR, En_pin, Rw_pin, Rs_pin, D4_pin, D5_pin, D6_pin, D7_pin);

class baseFunctions {
  public:
    baseFunctions() {
      Serial.begin(115200); // Housekeeping stuff
      esp8266.begin(115200);  // Housekeeping stuff
      sendData("AT+RST\r\n", 2000, DEBUG); // reset module

      // Code for display
      lcd.begin (16, 2);
      lcd.setBacklightPin(BACKLIGHT_PIN, POSITIVE);
      lcd.setBacklight(HIGH); // Switch on the backlight
      lcd.home (); // go home
      lcd.print("In development");

      pinMode(8, OUTPUT);
    }

    String sendData(String command, const int timeout, boolean debug) {
      String response = "";
      esp8266.print(command); // send the read characte to esp8266
      long int time = millis();
      while ( (time + timeout) > millis() ) {
        while (esp8266.available()) {
          // The esp has data so display its output to serial window
          char c = esp8266.read(); // read the next character
          response += c;
        }
      }
      if (debug) {
        Serial.print(response);
      }
      return response;
    }

    void connectToWifi() {
      sendData("AT+CWMODE=1\r\n", 3000, DEBUG); // Configure as clint
      sendData("AT+CWJAP=\"moto g\", \"hvats555\"\r\n", 5000, DEBUG);  // Connects to wifi
    }

    String fetchJson() {
      StaticJsonBuffer<200> jsonBuffer;
      char json[] = "{\"power\":\"high\"}";
      JsonObject& root = jsonBuffer.parseObject(json);

      const char* power = root["power"];
      return power;
    }
};

void setup() {
  baseFunctions go;
}

void loop() {
}

Here is the error
exit status 1
'esp8266' was not declared in this scope


user4143: When you added the class you obviously deleted/moved code into it from elsewhere.
One bit of code that you missed in that moving around will be the code that declares what esp8266 is:
SoftwareSerial esp8266(2,3); // for example

Find that in your original code and copy it across.

39817: <p>Below code was working fine without using classes, after using class an error pops up: esp8266 is not defined in this scope</p>

<pre class="lang-cpp prettyprint-override"><code>#include&lt;SoftwareSerial.h&gt;
#include&lt;ArduinoJson.h&gt;
#include&lt;Wire.h&gt;
#include&lt;LCD.h&gt;
#include&lt;LiquidCrystal_I2C.h&gt;
#include&lt;SPI.h&gt;

#define DEBUG true
// Housekeeping stuff for LCD display
#define I2C_ADDR    0x3F
#define BACKLIGHT_PIN     3
#define En_pin  2
#define Rw_pin  1
#define Rs_pin  0
#define D4_pin  4
#define D5_pin  5
#define D6_pin  6
#define D7_pin  7
LiquidCrystal_I2C
lcd(I2C_ADDR, En_pin, Rw_pin, Rs_pin, D4_pin, D5_pin, D6_pin, D7_pin);

class baseFunctions {
  public:
    baseFunctions() {
      Serial.begin(115200); // Housekeeping stuff
      esp8266.begin(115200);  // Housekeeping stuff
      sendData("AT+RST\r\n", 2000, DEBUG); // reset module

      // Code for display
      lcd.begin (16, 2);
      lcd.setBacklightPin(BACKLIGHT_PIN, POSITIVE);
      lcd.setBacklight(HIGH); // Switch on the backlight
      lcd.home (); // go home
      lcd.print("In development");

      pinMode(8, OUTPUT);
    }

    String sendData(String command, const int timeout, boolean debug) {
      String response = "";
      esp8266.print(command); // send the read characte to esp8266
      long int time = millis();
      while ( (time + timeout) &gt; millis() ) {
        while (esp8266.available()) {
          // The esp has data so display its output to serial window
          char c = esp8266.read(); // read the next character
          response += c;
        }
      }
      if (debug) {
        Serial.print(response);
      }
      return response;
    }

    void connectToWifi() {
      sendData("AT+CWMODE=1\r\n", 3000, DEBUG); // Configure as clint
      sendData("AT+CWJAP=\"moto g\", \"hvats555\"\r\n", 5000, DEBUG);  // Connects to wifi
    }

    String fetchJson() {
      StaticJsonBuffer&lt;200&gt; jsonBuffer;
      char json[] = "{\"power\":\"high\"}";
      JsonObject&amp; root = jsonBuffer.parseObject(json);

      const char* power = root["power"];
      return power;
    }
};

void setup() {
  baseFunctions go;
}

void loop() {
}
</code></pre>

<p>Here is the error</p>

<pre class="lang-none prettyprint-override"><code>exit status 1
'esp8266' was not declared in this scope
</code></pre>
 4143: <p>When you added the class you obviously deleted/moved code into it from elsewhere.</p>

<p>One bit of code that you missed in that moving around will be the code that declares what <code>esp8266</code> is:</p>

<pre><code>SoftwareSerial esp8266(2,3); // for example
</code></pre>

<p>Find that in your original code and copy it across.</p>
