octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #49421] Can't set properties in a subclass aft


From: Abhinav Tripathi
Subject: [Octave-bug-tracker] [bug #49421] Can't set properties in a subclass after chaining constructors in base class
Date: Sat, 17 Dec 2016 20:34:02 -0000
User-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.71 Safari/537.36

Follow-up Comment #3, bug #49421 (project octave):

Apparently we will have to copy each property from base to derived for this to
work (just a work-around).. I have to change the derived class to the
following then it works perfectly:  
```
classdef derived < base
  properties
    z;
  end
  methods
    function self = derived (a, b, c)
        if nargin<3
            c = 42;
        end
        if nargin<2
            b = pi;
        end
        if nargin<1
            a = 0;
        end
      s = base (a, b);
      self = derived.copy(self, s);
      self = builtin ('subsasgn', self, substruct ('.', 'z'), c);
    end
  end
  
  methods(Static)
       function obj = copy(obj,superobj)
          prop = properties(superobj);
          for i = 1:length(prop)
              obj.(prop{i}) = superobj.(prop{i});
          end
       end
  end
end
```

    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?49421>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]