Translate C++ to D

Luca Lupo luca.lupo at hotmail.it
Thu Jan 10 05:36:54 PST 2008


Thanks to everybody for the help, I have converted the other files .h to D I post it now, somebody can said me if it's well?

Thanks

//Observer.h

#include<string>
using namespace std;

class Subject;

class Observer{
      public:
             virtual ~Observer();
             virtual void Update(Subject* the_change_subject) = 0;
      protected:
             Observer();
      };

class Subscriber : public Observer{
      private:
             string indirizzo_e_mail;
      public:
             void Update(Subject* );
      };

class SubscriberG : public Subscriber{
      private:
              string indirizzo_e_mail_G;
      public:
             SubscriberG(string );
             void Update(Subject* );
      };

class SubscriberS : public Subscriber{
      private:
              string indirizzo_e_mail_S;
              string name_author;
      public:
             SubscriberS(string ,string);
             void Update(Subject* );
      };





//Observer_D.h.

import string;


class Subject;

class Observer{
      public:
             ~Observer();
             void Update(Subject* the_change_subject) = 0;
      protected:
             this();
      };

class Subscriber : public Observer{
      private:
             string indirizzo_e_mail;
      public:
             void Update(Subject* );
      };

class SubscriberG : public Subscriber{
      private:
              string indirizzo_e_mail_G;
      public:
             SubscriberG(string );
             void Update(Subject* );
      };

class SubscriberS : public Subscriber{
      private:
              string indirizzo_e_mail_S;
              string name_author;
      public:
             SubscriberS(string ,string);
             void Update(Subject* );
      };






//Post.h

#include<string>
using namespace std;

class Post{
      private:
             string Title;
             string Text;
             string Author;
      public:
             Post(string ,string ,string);
             void print();
             string print_Title();
             void print_Line();
             string print_Author();
             string print_Text();
      };





//Post_d.h

import string;


class Post{
      private:
             string Title;
             char *Text;
             string Author;
      public:
             Post(string ,char* ,string);
             void print();
             string print_Title();
             void print_Line();
             string print_Author();
             string print_Text();
      };






//Subject.h

#include<list>
#include"Observer.h"
#include"Post.h"
using namespace std;

class Subject{
      private:

      public:
             list<Observer*> _observer;
             virtual ~Subject();
             virtual void Attach(Observer *);
             virtual void Detach(Observer *);
             virtual void Notify();  //Per tutti gli oggetti nella lista chiama Update()
   protected:
             Subject(); //Puo essere chiamata SOLO dalle classi derivate
      };

class Blog : public Subject{
      private:
              string Blog_name;
              list<Post> l_post;
      public:
             Blog(string );
             void Notify();  //Per tutti gli oggetti nella lista chiama Update()
             void NewPost(Post);
             string GetName();
             void GetText();
             void GetTitle();  //Titolo dell ultimo post
             string GetAuthor();
             void GetLine();
      };




//Subject_d.h

import std.slist;
import Observer;
import Post;

class Subject{
       private:
       public:
               // Functions are virtual by default
               Slist!(Observer *) _observer; // is Observer*
               ~Subject();
               void Attach(Observer *); // is Observer*
               void Detach(Observer *); // is Observer*
               void Notify();  
       protected:
               this();
       }

class Blog : public Subject{
       private:
               string Blog_name;
               Slist!(Post) l_post;
       public:
               // If no overloading by derived classes, 
               // compiler will make non-virtual
              Blog(string );
              void Notify(); 
              void NewPost(Post); // is Post
              string GetName();
              void GetText();
              void GetTitle();  
              string GetAuthor();
              void GetLine();  
       };




I would known if also the file include of D have the extension.h

Thanks



More information about the Digitalmars-d mailing list