Hi everyone,
I am trying to create a simple librairy.
For Calculette one; I have the following errors:
myClass.h: No such file or directory
if I use #include "myClass.h" in the myClass folder:
myClass:6:1: error: 'Calculette' does not name a type
Why does IDE 1.8.10 does not accept the files sructure?
I tried to put the H and CPP files in a src folder (myClass/src , myClass/myClass/myClass.ino) without success.
I joined a zip file , in case and a phootograph of the folders structure.
I visited the Morse example, the Oreilly.Arduino.Cookbook.2nd.Edition.Dec.2011.pdf example: dumb I am stuck.
Regards,
JPDaviau
INO file
#include <myClass.h>
Calculette one;
void setup() {
one.calculette(2, 4);
one.exposant(); // from constructed class _variables
one.exposant(2, 4);
}
void loop() {
// put your main code here, to run repeatedly:
}
H file
#ifdef _c
#error This source file is not C but rather C++.
#endif
/* */
#ifndef myClass_H
#define myClass_H
// extern myClass calculette;
#endif
#if ARDUINO >= 100
#include "Arduino.h" // for 1.0 and later
#else
#include "WProgram.h" // for earlier releases #endif
#include <iostream>
#include <cmath>
class Calculette
{
private:
int _base;
int _pow;
public :
calculette (uint_8_t number, uint_8_t exposant); ////construct
~calculette(); //destruct
Calculette::calculette (uint_8_t number, uint_8_t exposant);
void Calculette::exposant();
int Calculette::exposant(uint_8_t number, uint_8_t exposant);
};
//extern myClass2 fonctionner;
#endif
CLASS file
#ifdef _c
#error This source file is not C but rather C++.
#endif
#include <myClass>
using std::cout; // le programme utilise cout.
using std::cin; // le programme utilise cin.
using std::endl; // le programme utilise endl.
class Calculette
{
private:
int _base;
int _pow;
public :
calculette (uint_8_t number, uint_8_t exposant);////construct
~calculette(); //destruct
void exposant();
int exposant(uint_8_t number, uint_8_t exposant);
Calculette::calculette (uint_8_t number, uint_8_t exposant)
{
_pow = number;
_base = exposant;
}
Calculette::~calculette(){}
void Calculette::exposant()
{
unsigned int out;
for (int x = 2, int y = 2; y < 9; y += 2)
{
out = pow(_base, _pow);
}
if (out > 60000)
{
return out;
}
else
{
printf("Number is over 60000.");
}
}
int Calculette::exposant(uint_8_t number, uint_8_t exposant)
{
unsigned int out;
for (int x = 2, int y = 2; y < 9; y += 2)
{
out = pow(number, exposant);
}
if (out > 60000)
{
return out;
}
else
{
printf("Number is over 60000.");
}
}
};
myClass.zip (3.28 KB)

