Translate C++ to D
Luca Lupo
luca.lupo at hotmail.it
Thu Jan 10 11:53:25 PST 2008
I would like to thank all the answers, you are very available. Now I have to start converting the files. Cpp and I hope that you can continue to help.
This is the first file: observer.cpp, any suggestions?
//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.string;
import Subject
Observer::~this() //distructor for observer
{}
Observer::this() // costructor for observer
{}
SubscriberG::this(string a) //contructor for subscriberG
{indirizzo_e_mail_G = a;}
SubscriberS::this(string a,string b) //contructor for subscriberS
{
indirizzo_e_mail_S = a;
name_author = b;
}
void Observer::Update(Subject* b) //it's equal? for me yes!
{}
void Subscriber::Update(Subject* b) //it's equal? for me yes!
{}
void SubscriberS::Update(Subject* b) //Help??
{
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) //Help??
{
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;
}
More information about the Digitalmars-d
mailing list