"Request for member ' ' in ' ', which is of non class type ' '"

You know what the error (title) means. I’m sure you’ve probably run across it too… If so, I’d appreciate some help! :sweat_smile:
I’ve been coming close to banging my head against the table for the last hour or so trying to figure out why I’m getting this error. Again. I’d really appreciate some help figuring out why I’m getting this error: “request for member ‘measureIMU/readIMU’ in ‘vector’, which is of non-class type ‘IMU () ()’”

.ino:

#include <IMU.h>

//Macros
#define  X  0

IMU  vector();

void setup()
{
  Serial.begin(9600);
}

void loop()
{
  vector.measureIMU();
  Serial.print(vector.readIMU(X));
  Serial.println();
}

.h:

#ifndef IMU_H
#define IMU_H
#include    "Arduino.h"

class IMU
{
public:
    IMU();
    void measureIMU();
    byte readIMU(byte axis);
private:
    ...
};

#endif

.cpp:

#include    <Arduino.h>
#include    "IMU.h"

...

//Initializer
IMU::IMU()
{
    init();
    ...
}

byte IMU::readIMU(byte axis)
{
    ...
}

void IMU::measureIMU()
{
    ...
}
...
IMU  vector();

Lose the brackets.

Ohhh right! Hahahahaha thanks!

Arduino:1.8.1 (Windows 7), Tarjeta:“Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)”

request for member ‘minute’ in ‘now’, which is of non-class type ‘time_t() {aka long unsigned int()}’

lcd.print(now.minute(), DEC);

^

I Have some ploblems too, could you help me please

Same answer.

According to :
https://www.arduino.cc/en/Hacking/LibraryTutorial

#include <Morse.h>

Morse morse(13);   <----- This line

One can see when declaring an instance of the object, brackets were used (yes obviously because a parameter was passed in). Surely the difference of passing in default values or not should change whether if brackets are used it creates a compile error or not?

I have the same problem. I also based my class on the Arduino sample code using Morse

my class defines a public function:

void bbegin();

and the code for the function:

void RemoteSign::bbegin() {
   _rsserver.begin();   // _rsserver is an object of type WiFiServer
}

Compiler barfs on the single line with:

request for member 'begin' in '_rsserver', which is of non-class type 'WiFiServer()'

mangelozzi: Surely the difference of passing in default values or not should change whether if brackets are used it creates a compile error or not?

Yes, it will generate a compiler error. However, the error will occur when you are trying to access any member function or variables of "morse". That is, because

Morse morse();

is perfectly fine for the compiler. You are declaring a function called morse, which takes no arguments and returns a Morse object. When you are trying to access morse.dot() for example, the compiler will create an error, because the "morse" is in fact of type "Morse(void)" (a function) and not of type "Morse" (a class).

1 Like

i want to print message if message starts with "$GPGGA"..but i get error.

thats my code.........................

char message[]=" $GPGGA,123519,4807.038,N,01131.000,E,1,08,0.9,545.4,M,46.9,M,,*47"; void setup(){ Serial.begin(9600); }

void loop(){ if(message.startsWith("$GPGGA")){

//Serial.println(message); char*next;// pointer to substring(token) float value; next=strtok(message,",");// get first substring token Serial.println(next);//print GPGGA Serial.print("UTC: ");//print universal time UTC (next=strtok(NULL,","));//print next string 123519 value=atof(next);// convert string to float Serial.println(value,0);

Serial.print("latitude: ");//print latitude (next=strtok(NULL,","));//print next string value=atof(next); Serial.println(value,3); Serial.print("Direction: ");// print direction (next=strtok(NULL,",")); Serial.println(next);

Serial.print("longitude: ");//print longitude (next=strtok(NULL,",")); value=atof(next); Serial.println(value,3); Serial.print("Direction: ");// print direction (next=strtok(NULL,",")); Serial.println(next);

Serial.print("fix quality: "); (next=strtok(NULL,",")); value=atof(next); Serial.println(value,0);

Serial.print("NO. of Satellites teacked: "); (next=strtok(NULL,",")); value=atof(next); Serial.println(value,0);

Serial.print("Horizontal dilution position: ");//print longitude (next=strtok(NULL,",")); value=atof(next); Serial.println(value,2);

Serial.print("Altitude,meters: "); (next=strtok(NULL,",")); value=atof(next); Serial.print(value ,2); (next=strtok(NULL,",")); Serial.print(","); Serial.println(next);

Serial.print("Height,meters: ");// (next=strtok(NULL,",")); value=atof(next); Serial.print(value ,2); (next=strtok(NULL,",")); Serial.print(","); Serial.println(next);

Serial.print("check sum : ");//print check sum data (next=strtok(NULL,",")); Serial.println(next); } }