I implemented an example class Demo, with an overloaded function run. The function run has a different implementation depending on whether it is called from an immutable instance of an object or a mutable instance. Is it also possible to create yet another version of run that runs when we call it from an anonymous function? i.e.,
Demo().run;
Here is the code so far.
#include <iostream>
using namespace std;
class Demo {
  public:
   Demo() { }
   void run() { cout << "Called from object or from function expecting a reference to object" << '\n'; }
   const void run() const { cout << "Called from const object" << '\n'; }
 };
int main(){
    const Demo obt;
    Demo obt2;
    obt2.run();
    obt.run();
    Demo().run();
}
The output is
Called from object or from function expecting a reference to object
Called from const object
Called from object or from function expecting a reference to object
so right now the Demo().run() sees the temporary anonymous class Demo() as a normal class.