Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Pascal/C++ TYS
Index -> General Programming
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
wtd




PostPosted: Tue Dec 12, 2006 2:07 am   Post subject: Pascal/C++ TYS

Translate the following code into Pascal, in a source file called foo.pas such that it compiles with:

code:
fpc -S2 foo


code:
#include <iostream>

class Foo
{
   public:
      virtual int foo() const = 0;
};

class Bar : public virtual Foo
{
   public:
          virtual int bar() const = 0;
          virtual int baz() const;
};

class Baz : public virtual Bar
{
   public:
      Baz(int w = 1, int n = 2);
          virtual ~Baz();
   
      virtual int foo() const;
          virtual int bar() const;
          
   private:
      int wooble, ninja;
};

int main()
{
   Bar *qux = new Baz(1, 3);
   
   std::cout << qux->baz() << std::endl;
}

int Bar::baz() const
{
   return foo() + bar();
}

Baz::Baz(int w, int n) : wooble(w), ninja(n)
{
}

Baz::~Baz()
{
}

int Baz::foo() const
{
   return wooble;
}

int Baz::bar() const
{
   return ninja;
}
Sponsor
Sponsor
Sponsor
sponsor
bugzpodder




PostPosted: Thu Dec 14, 2006 8:38 pm   Post subject: (No subject)

what is TYS
[Gandalf]




PostPosted: Thu Dec 14, 2006 8:48 pm   Post subject: (No subject)

Test Your Skills.

Sadly, I have no clue how to do this one. Partially because I don't know any non-Turing Pascal.
md




PostPosted: Thu Dec 14, 2006 9:59 pm   Post subject: (No subject)

I've been meaning to do this, but I find my free time is lacking (in between parties and all... damn those open bar parties...)

this http://attachr.com/5371 may help anyone interested, thanks to the wonderful wtd Smile
Display posts from previous:   
   Index -> General Programming
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 4 Posts ]
Jump to:   


Style:  
Search: