[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
creating another object of a given class
From: |
Steve White |
Subject: |
creating another object of a given class |
Date: |
Thu, 23 Dec 2010 00:11:27 +0100 |
What is the best way to create another object of a given class?
Say a function takes an object as an argument
and a new object of that class is needed.
One way to do it (for an object 'obj') is
name = class (obj);
new_obj = feval (name, args);
However, the Coding-Tips documentation entry says to avoid calling
feval "excessively":
http://www.gnu.org/software/octave/doc/interpreter/Coding-Tips.html#Coding-Tips
Another option would be to attach a function handle to the
constructor of each class as an object member, and call that
when needed. But this seems cludgy.
Is there a better/faster/accepted way to do this?
- creating another object of a given class,
Steve White <=