If i have file cSpeedOfSound.h:
#ifndef cSpeedOfSound_h
#define cSpeedOfSound_h
#include "Arduino.h"
#include "math.h"
class cSpeedOfSound{
public:
cSpeedOfSound(float *i,float *C);
private:
float *C;
float *a;
float *i;
};
#endif
and file cSpeedOfSound.cpp:
#include "cSpeedOfSound.h"
cSpeedOfSound::cSpeedOfSound(float *i,float *C){
//some code...
*C =roundto(*C,2);}
float cSpeedOfSound::roundto(float x,float dp){
return (round(x*pow(10., dp)) / pow(10., dp));}
where i want to run function roundto inside class, but it doesnt seems to work. So what im making wrong and how to do it properly?
Ps: Im begginer to arduino (want it to learn robotics + C language) and know python (learnd for about 1+ year), so pls do not hate me if i made crucial mistakes.
roundto()
as a plain function. Declare it asstatic
to make it visible only from inside cSpeedOfSound.cpp. That's the C way of encapsulation.