Creating library : expected unqualified-id before '.' token

Getting expected unqualified-id before ‘.’ token for class testlib.setup_system() and testlib.looping_system
Help me please with the codes

header file

#ifndef testlib_h
#define testlib_h
#include <inttypes.h>
#include <Arduino.h>
class testlib
{
  public:
    void setup_system();
    void looping_system();

  private:
};
#endif

cpp file

#include <inttypes.h>
#include <Wire.h>
#include <Arduino.h>
#include <SHT2x.h>
#include <Ethernet.h>
#include <SPI.h>
#include "testlib.h"




void testlib::setup_system()
{
  IPAddress ip(192, 168, 1, 129);
  EthernetClient client;
  EthernetServer server(80);

  byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //Setting MAC Address




  if (Ethernet.begin(mac) == 0)
  {

  }
  else
  {
    Ethernet.begin(mac, ip);

    server.begin();

  }
  // delay(1000);
}


void testlib::looping_system()
{

  float humidityData;
  float temperatureData;

  IPAddress ip(192, 168, 1, 129);
  EthernetServer server(80);
  EthernetClient client = server.available();



  humidityData = (SHT2x.GetHumidity());


  temperatureData = (SHT2x.GetTemperature());




  // listen for incoming clients

  if (client) {

    // an http request ends with a blank line
    boolean currentLineIsBlank = true;
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        Serial.write(c);
        // if you've gotten to the end of the line (received a newline
        // character) and the line is blank, the http request has ended,
        // so you can send a reply
        if (c == '\n' && currentLineIsBlank) {
          // send a standard http response header
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println("Connection: close");  // the connection will be closed after completion of the response
          client.println("Refresh: 5");  // refresh the page automatically every 5 sec
          client.println();
          client.println("<!DOCTYPE HTML>");
          client.println("<html>");
          // output the value of sensor data


          client.print("temperature value is: ");
          client.print(temperatureData);
          client.println("humidity value is: ");
          client.print(humidityData);
          client.println("
");

          client.println("</html>");
          break;
        }
        if (c == '\n') {
          // you're starting a new line
          currentLineIsBlank = true;
        } else if (c != '\r') {
          // you've gotten a character on the current line
          currentLineIsBlank = false;
        }
      }
    }
    // give the web browser time to receive the data
    delay(1);
    // close the connection:
    client.stop();

  }
}

and ino code

#include "testlib.h"
#include "Wire.h"

#include "testlib.h"
#include "Wire.h"


void setup() {
  Serial.begin(9600);
  Wire.begin();
  testlib.setup_system();

}

void loop() {
  testlib.looping_system();

stuck for two days

error details:

\Documents\Arduino\libraries\testlib\testlib\testlib.ino: In function ‘void setup()’:

testlib:8:10: error: expected unqualified-id before ‘.’ token

testlib.setup_system();

^
\Documents\Arduino\libraries\testlib\testlib\testlib.ino: In function ‘void loop()’:

testlib:13:10: error: expected unqualified-id before ‘.’ token

testlib.looping_system();

testlib.cpp (2.53 KB)

testlib.h (220 Bytes)

testlib.ino (182 Bytes)

Please post the full error messages

you imported your library so testlib class name is known but you did not instanciate any object in your .ino


Please correct your post above and add code tags around your code:

[code]

[color=blue]// your code is here[/color]

[/code]

.

It should look like this:

// your code is here

(Also press ctrl-T (PC) or cmd-T (Mac) in the IDE before copying to indent your code properly)

J-M-L:
you imported your library so testlib class name is known but you did not instanciate any object in your .ino


Please correct your post above and add code tags around your code:

[code]

[color=blue]// your code is here[/color]

[/code]

.

It should look like this:

// your code is here

(Also press ctrl-T (PC) or cmd-T (Mac) in the IDE before copying to indent your code properly)

i'm somewhat new to this. can you please elaborate how to do away with it?

that's object oriented programing 101... have you read anything about classes and objects? Your class defines a "model" and unless you specially craft it, in order to use it you need to create "a sample" (an object, instantiate the class) of that class.

Have you used any library, anything like a sensor or a LED matrix, an RTC etc ?
You'll see that after importing the library, a variable from that class is created.

J-M-L:
that's object oriented programing 101... have you read anything about classes and objects? Your class defines a "model" and unless you specially craft it, in order to use it you need to create "a sample" (an object, instantiate the class) of that class.

Have you used any library, anything like a sensor or a LED matrix, an RTC etc ?
You'll see that after importing the library, a variable from that class is created.

thank you so much. the problem has been solved for now.

#include "testlib.h"
#include "Wire.h"

testlib testcase;
void setup() {
  Serial.begin(9600);
  Wire.begin();

  testcase.setup_system();

}

void loop() {
  testcase.looping_system();


}

[\code]

however, I'm up for another trouble which I have posted as a new topic. Can you please see it and help me out?

https://forum.arduino.cc/index.php?topic=673971.0