Anonymous user
Object serialization: Difference between revisions
m
Spelling/grammar/aesthetics
m (Alphabetized) |
m (Spelling/grammar/aesthetics) |
||
Line 1:
{{task}}
Create a set of data types based upon inheritance. Each data type or class should have a print command that displays the contents of an instance of that class to standard output. Create instances of each class in your inheritance hierarchy and display them to standard output. Write each of the objects to a file named ''objects.dat'' in binary form using serialization or marshalling.
=={{header|Ada}}==
Line 198:
=={{header|PHP}}==
Serialization in PHP is straightforward.
$myObj = new Object();
$serializedObj = serialize($myObj);
In order to
=={{header|Python}}==
Line 246:
=={{header|Ruby}}==
class Being
def initialize(
@
end
def to_s
"(object_id = #{object_id})\n"+"(#{self.class}):".ljust(12)+to_s4Being+(@
end
def to_s4Being
Line 263:
end
class
def initialize(type)
@type=type
end
def to_s4Earthling
"I am champion in taking care of my offspring and eating
end
end
Line 289:
diverseCollection=[]
diverseCollection << (marsian=Being.new("I come from Mars and like playing hide and seek."))
diverseCollection << (me=
diverseCollection << (nemo=Fish.new(0.99))
diverseCollection << (jannakeMaan=Moonling.new)
|