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. Read the file objects.dat and print the contents of each serialized object.

 
abstract type Hello end
 
struct HelloWorld <: Hello
    name::String
    HelloWorld(s) = new(s)
end
 
struct HelloTime <: Hello
    name::String
    tnew::DateTime
    HelloTime(s) = new(s, now())
end
 
sayhello(hlo) = println("Hello to this world, $(hlo.name)!")
 
sayhello(hlo::HelloTime) = println("It is now $(now()). Hello from back in $(hlo.tnew), $(hlo.name)!")
 
h1 = HelloWorld("world")
h2 = HelloTime("new world")
 
sayhello(h1)
sayhello(h2)
 
fh = open("objects.dat", "w")
serialize(fh, h1)
serialize(fh,h2)
close(fh)
 
sleep(10)
 
fh = open("objects.dat", "r")
hh1 = deserialize(fh)
hh2 = deserialize(fh)
close(fh)
 
sayhello(hh1)
sayhello(hh2)
 