Translate C++ to D
Luca Lupo
luca.lupo at hotmail.it
Fri Jan 11 09:01:47 PST 2008
So this files is correctly converted from .cpp to .d??
//Observer.cpp
#include<iostream>
#include<string>
#include"Subject.h"
using namespace std;
Observer::~Observer()
{}
Observer::Observer()
{}
SubscriberG::SubscriberG(string a){
indirizzo_e_mail_G = a;
}
SubscriberS::SubscriberS(string a,string b){
indirizzo_e_mail_S = a;
name_author = b;
}
void Observer::Update(Subject* b)
{}
void Subscriber::Update(Subject* b)
{}
void SubscriberS::Update(Subject* b){
if (name_author == ((Blog *)b)->GetAuthor()){
cout<<"Subscriber tipo S->"<<"Name blog: "<<((Blog *)b)->GetName()<<endl;
((Blog *)b)->GetTitle();
((Blog *)b)->GetText();
cout<<"Autore Ultimo Post :"<<((Blog *)b)->GetAuthor();
cout<<endl<<endl;
}
}
void SubscriberG::Update(Subject* b){
cout<<"Subscriber tipo G->"<<"Name blog: "<<((Blog *)b)->GetName()<<endl;
((Blog *)b)->GetTitle();
((Blog *)b)->GetLine();
cout<<"Autore Ultimo Post :"<<((Blog *)b)->GetAuthor();
cout<<endl<<endl;
}
//Observer.d
import std.stdio;
import std.string;
import Subject
class Observer{
~this(){} //distructor for observer
this(){} // costructor for observer
Update(Subject* b){}
}
class Subscriber{
Update(Subject* b);
}
class SubscriberG{
this (string a){
indirizzo_e_mail_G = a;
}
Update (Subject* b){
writefln("Subscriber tipo G->", "Name blog: ", ((Blog *)b).GetName());
((Blog *)b).GetTitle();
((Blog *)b).GetLine();
writefln("Autore Ultimo Post: ",((Blog *)b).GetAuthor());
writefln("");
writefln("");
}
}
class SubscriberS{
this (string a, string b){
indirizzo_e_mail_S = a;
name_author = b;
}
Update (Subject* b){
if (name_author == ((Blog *)b).GetAuthor()){
writefln("Subscriber tipo S->", "Name blog: ", ((Blog *)b).GetName());
((Blog *)b).GetTitle();
((Blog *)b).GetText();
writefln("Autore ultimo Post: ",((Blog *)b).GetAuthor());
}
writefln("");
writefln("");
}
}
More information about the Digitalmars-d
mailing list