Is that really what OP was asking for ?
Sure looks like it to me. From Post #1:
Ok I see
I thought dateConvert() was a function returning something that would not be an instance of anything was the question.
I think this comes close to what OP wants...
You could do the same in other ways, but using a class may allow additions that can only be done with classes...
class triangle {
public:
static float surface(float height, float base);
};
float triangle::surface(float height, float base) {
return height * base * 0.5;
}
void setup {
Serial.begin(9600);
Serial.println(triangle::surface(10, 10));
}
void loop() {
}
I tested the code in Xcode (C++ on Mac) and adopted it to Arduino code without testing...
Thank you for this example. This is exactly the solution I'm looking for. I've now learned that this feature works with every class - this I didn't know yet.
Thank you @all for your greatful support.
regards
Frank
OK - you do have an invisible instance
When Serial.println(myClass(123456).formatPrint()) is called, a temporary instance of myClass is created. Its formatPrint() method returns a pointer to a char buffer inside this temporary object. The buffer remains valid just long enough for Serial.println() to read and cache its content, after which the temporary object is destroyed and the pointer becomes invalid and goes out of scope.