Hi everyone.
I'd like to create a class that is associated to another class in some sort of parent-child relationship. For this the "child" class needs a reference to it's parent.
For example:
template <typename T>
class TEvent {
    private: T* Owner;
    public: TEvent(T* parent) : Owner(parent) {}
};
class Foo {
    private: TEven...
            
           
          
            
            I want to do this in Javascript:
function Z( f )
{
  f();
}
function A()
{
  this.b = function()
  {
    Z( function () { this.c() } );
  }
  this.c = function()
  {
    alert('hello world!');
  }
}
var foo = new A();
foo.b();
It can be accomplished this way:
function Z( f )
{
  f();
}
function A()
{
  var self = this;
  this.b =...
            
           
          
            
            say I create someObj like this
var someObj = function(){
  var self = this;
  //use this normally
  document.body.addEventListener('click',function(){
     //use self because this is unavailable
  },false)
}
new someObj();
In the event this is not the someObj which id like to use but in this case the body element. Is there a best prac...
            
           
          
            
            Basically what I'm trying to achieve is to make the object reference another object of the same class - from inside of a method. It'd be perfect if the following would work:
$this = new self;
But one cannot reassign $this in php. 
I of course know, I can return another object from the method and use that, so please do not advise that...