help with simple inheritance
Posted: Sun Mar 22, 2020 7:30 pm
I was trying to add some custom methods to a base class using inheritance but I just can't get my head around this and it keeps failing compilation.
I'm probably making some basic stupid error, please have a look:
Compiler output:
I'm probably making some basic stupid error, please have a look:
Code: Select all
#include "FS.h"
class Filesystem : public FS {
public:
void Filesystem::mount() {
if (!Filesystem::begin())
{
Serial.println("Failed to mount file system");
}
else {
Serial.println("File system mounted.");
}
}
}myFiles;
void setup() {
Serial.begin(115200);
Serial.println("Mounting FS...");
myFiles.mount();
}
void loop() {
}
Compiler output:
Code: Select all
Compiling 'filesystem' for 'Generic ESP8266 Module'
filesystem.ino: 6:10: error: extra qualification 'Filesystem::' on member 'mount' [-fpermissive]
void Filesystem*: mount() {
filesystem.ino: 16:2: error: use of deleted function 'Filesystem::Filesystem()
}myFile
filesystem.ino:4: note Filesystem Filesystem() is implicitly deleted because the default definition would be ill-formed
class Filesystem *: public FS {
filesystem.ino: 4:7: error: no matching function for call to 'fs::FS::FS()
Error compiling project sources
filesystem.ino:4: note candidates are
filesystem.ino:2: In file included from
FS.h:201: note fs FS FS(fs FSImplPtr)
FS(FSImplPtr impl) *: _impl(impl) { timeCallback = _defaultTimeCB; }
FS.h:201: note candidate expects 1 argument, 0 provided
FS.h:198: note fs FS FS(const fs FS&)
class FS
FS.h:198: note candidate expects 1 argument, 0 provided
FS.h:198: note fs FS FS(fs FS&&)
FS.h:198: note candidate expects 1 argument, 0 provided
Build failed for project 'filesystem'