Translate C++ to D
bearophile
bearophileHUGS at lycos.com
Fri Jan 11 09:27:59 PST 2008
Janice Caron:
> Instead of
> cout<<"Subscriber tipo G->"<<"Name blog: "<<((Blog *)b).GetName()<<endl;
> do
> writefln("Subscriber tipo G->", "Name blog: ", ((Blog *)b).GetName());
I think it may be necessary a cast there:
writefln("Subscriber tipo G->Name blog: ", (cast(Blog*)b).GetName );
But be careful because the first string can't contain spurious %. D 2.x has write/writeln to solve that (silly) bug.
Anyway, I suggest against this kind of translation, I suggest an incremental way of doing such thing. That is translate a tiny working piece of C++ code, make it work, and then add more and more code, keeping it more or less working... unit tests help a lot. This isn't always possible, but doing otherwise is a good way to put lot of bugs in the translated code.
Bye,
bearophile
More information about the Digitalmars-d
mailing list