I wish to extend capabilities of the class tinyFAT. For instance, to add a method allowing to create a file from a String variable. the code is as follows :
#include <tinyFAT.h>
class TinyFAT_M: public tinyFAT {
public:
TinyFAT_M();
boolean create(String fc);
};
TinyFAT_M::TinyFAT_M() : tinyFAT() {
}
boolean TinyFAT_M::create(String fc) {
char buf[fc.length()+1];
fc.toCharArray(buf, fc.length()+1);
create(buf);
}
TinyFAT_M mySD;
void setup() {
mySD.initFAT(); // it semms that this is oK ?
String fch = "NewTexte";
mySD.create(fch);
}
void loop() {
}
This compiles fine, but no file is created when launched.
nid69ita:
What is the create() function that you call on TinyFAT_M::create() member?
I read in a C++ course that the compiler was able to distinguish bewteen several methods with the same name provided that the parameters were different in type or number. So I thought that this was true even if one method was in the parent class and the other in a child class Seemingly, it is not the case.
I have replaced, in my child class the method name "create" by "createSD" and now, it works.
But, is there a way to keep the same name in the two classes. For instance to use a special term (inherited in Pascal) to call the method of the parent class ?
nid69ita:
...I think it's necessary to close the file.