Skip to main content
Rollback to Revision 2
Link
user26383
  • 81
  • 1
  • 10

Error in Creating a Library - request for member ... which is of non-class typeHelp with errors

I am changing the title to more accurately reflect my current issue.
Link
user26383
  • 81
  • 1
  • 10

Error in Creating a Library Help with errors- request for member ... which is of non-class type

I have updated the Code and the errors to reflect the changes and hopefully help anyone with this error in the future.
Source Link
user26383
  • 81
  • 1
  • 10
/* Morse.h - Library for flashing Morse code.
Created by Young on Sept. 1, 2016 */

#ifndef Morse_h
#define Morse_h

#include "Arduino.h"

class Morse
{
public:
Morse(int LED);
Morse(, int BEEP);
Morse(, int delayTime);
Morse(, char tmpChar);

void MorseDot();
void MorseDash();
void LightsOff(int delayTime);
void GetChar(char tmpChar);

private:
int _LED;
int _BEEP;
int _delayTime;
char _tmpChar;
int _note;
int _dotLen;
int _dashLen;
int _elemPause;
int _Spaces;
int _wordPause;
};

#endif
#include <Morse.h>

int delayTime;
int tmpChar;

Morse dot();
Morse dash();
Morse dark(int delayTime); 
Morse set(char tmpChar);

char stringToMorseCode[] = "N 36° 00.19518   W 084° 13.88856";    //Final Coordinates

// Create variable to define the output pins
int LED = 13;      // blink an led on output 12
int BEEP = 14;      // output audio on pin 8
int i;

void setup() 
{

}

void loop() 
{ 
// Loop through the string and get each character one at a time until the end is reached
for (int i = 0; i < sizeof(stringToMorseCode) - 1; i++);
{
// Get the character in the current position
char tmpChar = stringToMorseCode[i];
// Set the case to lower case
tmpChar = toLowerCase(tmpChar);
// Call the subroutine to get the morse code equivalent for this character
Morse set.GetChar(tmpChar);
}

// At the end of the string long pausepledause before looping and starting again
Morse::
dark.LightsOff(8000);            // hold in this position     

}
In file included from /Users/Young1DMYoung1/Documents/Arduino/Morse_Library_Test/Morse_Library_Test.ino:1:0:
/Users/Young1/Documents/Arduino/libraries/Morse/Morse.h:13:5: error: 'Morse::Morse(int)' cannotIn befunction overloaded
'void Morseloop(int BEEP);
 ^
/Users/Young1/Documents/Arduino/libraries/Morse/Morse.h':12
Morse_Library_Test:533: error: with 'Morse::Morse(int)'
 Morse(int LED);
 ^
/Users/Young1/Documents/Arduino/libraries/Morse/Morse.h:14:5:request error:for 'Morse::Morse(int)'member cannot'GetChar' bein overloaded
'set', Morse(intwhich delayTime);
is ^
/Users/Young1/Documents/Arduino/libraries/Morse/Morse.h:12:5:of error:non-class withtype 'Morse::Morse(intchar)'
 Morse(int LED set.GetChar(tmpChar);
 ^
/Users/Young1/Documents/Arduino/Morse_Library_Test/Morse_Library_Test.ino: In function 'void loop()':  ^
Morse_Library_Test:3138: error: cannotrequest callfor member function'LightsOff' 'voidin Morse::LightsOff'dark', which is of non-class type 'Morse(int)' without object
   Morse::dark.LightsOff(8000);      
       // hold in this position      
      ^
exit status 1
cannotrequest callfor member function'GetChar' 'voidin Morse::LightsOff'set', which is of non-class type 'Morse(intchar)' without object
/* Morse.h - Library for flashing Morse code.
Created by Young on Sept. 1, 2016 */

#ifndef Morse_h
#define Morse_h

#include "Arduino.h"

class Morse
{
public:
Morse(int LED);
Morse(int BEEP);
Morse(int delayTime);
Morse(char tmpChar);

void MorseDot();
void MorseDash();
void LightsOff(int delayTime);
void GetChar(char tmpChar);

private:
int _LED;
int _BEEP;
int _delayTime;
char _tmpChar;
int _note;
int _dotLen;
int _dashLen;
int _elemPause;
int _Spaces;
int _wordPause;
};

#endif
void loop() 
{ 
// Loop through the string and get each character one at a time until the end is reached
for (int i = 0; i < sizeof(stringToMorseCode) - 1; i++);
{
// Get the character in the current position
char tmpChar = stringToMorseCode[i];
// Set the case to lower case
tmpChar = toLowerCase(tmpChar);
// Call the subroutine to get the morse code equivalent for this character
Morse GetChar(tmpChar);
}

// At the end of the string long pause before looping and starting again
Morse::LightsOff(8000);      
}
In file included from /Users/Young1/Documents/Arduino/Morse_Library_Test/Morse_Library_Test.ino:1:0:
/Users/Young1/Documents/Arduino/libraries/Morse/Morse.h:13:5: error: 'Morse::Morse(int)' cannot be overloaded
 Morse(int BEEP);
 ^
/Users/Young1/Documents/Arduino/libraries/Morse/Morse.h:12:5: error: with 'Morse::Morse(int)'
 Morse(int LED);
 ^
/Users/Young1/Documents/Arduino/libraries/Morse/Morse.h:14:5: error: 'Morse::Morse(int)' cannot be overloaded
 Morse(int delayTime);
 ^
/Users/Young1/Documents/Arduino/libraries/Morse/Morse.h:12:5: error: with 'Morse::Morse(int)'
 Morse(int LED);
 ^
/Users/Young1/Documents/Arduino/Morse_Library_Test/Morse_Library_Test.ino: In function 'void loop()':
Morse_Library_Test:31: error: cannot call member function 'void Morse::LightsOff(int)' without object
   Morse::LightsOff(8000);      
                     ^
exit status 1
cannot call member function 'void Morse::LightsOff(int)' without object
/* Morse.h - Library for flashing Morse code.
Created by Young on Sept. 1, 2016 */

#ifndef Morse_h
#define Morse_h

#include "Arduino.h"

class Morse
{
public:
Morse(int LED, int BEEP, int delayTime, char tmpChar);

void MorseDot();
void MorseDash();
void LightsOff(int delayTime);
void GetChar(char tmpChar);

private:
int _LED;
int _BEEP;
int _delayTime;
char _tmpChar;
int _note;
int _dotLen;
int _dashLen;
int _elemPause;
int _Spaces;
int _wordPause;
};

#endif
#include <Morse.h>

int delayTime;
int tmpChar;

Morse dot();
Morse dash();
Morse dark(int delayTime); 
Morse set(char tmpChar);

char stringToMorseCode[] = "N 36° 00.19518   W 084° 13.88856";    //Final Coordinates

// Create variable to define the output pins
int LED = 13;      // blink an led on output 12
int BEEP = 14;      // output audio on pin 8
int i;

void setup() 
{

}

void loop() 
{ 
// Loop through the string and get each character one at a time until the end is reached
for (int i = 0; i < sizeof(stringToMorseCode) - 1; i++);
{
// Get the character in the current position
char tmpChar = stringToMorseCode[i];
// Set the case to lower case
tmpChar = toLowerCase(tmpChar);
// Call the subroutine to get the morse code equivalent for this character
set.GetChar(tmpChar);
}

// At the end of the string long pledause before looping and starting again

dark.LightsOff(8000);            // hold in this position     

}
/Users/DMYoung1/Documents/Arduino/Morse_Library_Test/Morse_Library_Test.ino: In function 'void loop()':
Morse_Library_Test:33: error: request for member 'GetChar' in 'set', which is of non-class type 'Morse(char)'
   set.GetChar(tmpChar);
       ^
Morse_Library_Test:38: error: request for member 'LightsOff' in 'dark', which is of non-class type 'Morse(int)'
 dark.LightsOff(8000);            // hold in this position      
      ^
exit status 1
request for member 'GetChar' in 'set', which is of non-class type 'Morse(char)'
Source Link
user26383
  • 81
  • 1
  • 10
Loading