tasks a-s
This commit is contained in:
parent
47bf37c096
commit
b83f433714
12433 changed files with 156208 additions and 123 deletions
35
Task/Object-serialization/D/object-serialization.d
Normal file
35
Task/Object-serialization/D/object-serialization.d
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
import test1;
|
||||
import std.stdio;
|
||||
import std.file;
|
||||
class full2:base2 {
|
||||
this(byte[]manip,bool isroot=true) {super(manip,isroot);}
|
||||
this(){super();}
|
||||
void print() {
|
||||
foreach(item;rep) {
|
||||
writefln(item.i32);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void main() {
|
||||
full2 base = new full2();
|
||||
base1 tmp = new base1;
|
||||
tmp.i32 = 34;
|
||||
base.add_rep(tmp);
|
||||
tmp = new base1;
|
||||
tmp.i32 = 32;
|
||||
base.add_rep(tmp);
|
||||
tmp = new base1;
|
||||
tmp.i32 = 33;
|
||||
base.add_rep(tmp);
|
||||
tmp = new base1;
|
||||
tmp.i32 = 36;
|
||||
base.add_rep(tmp);
|
||||
writefln("Input data:");
|
||||
base.print;
|
||||
write("objects.dat",base.Serialize());
|
||||
byte[]filedata = cast(byte[])read("objects.dat");
|
||||
base = new full2(filedata);
|
||||
writefln("Output data:");
|
||||
base.print;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue