Translate C++ to D

doob doobnet at gmail.com
Fri Jan 11 06:11:43 PST 2008


Luca Lupo wrote:
> So, I have converted the -> with the . , but I must make this also for:
> example:
> 
> Observer::~this(){} ??? :: no, but .??
> 
> And Exit the cout in D?? or I must import some library??
> 
> Thanks

You don't write classname::function, you put all the functions in the 
class like this:

class Observer
{
	this()
	{
		// do something
	}

	foo (int i)
	{
		// do something else
	}
}

But if you want to access a static function you replace the two colons 
with a dot like:

Observer.staticFunction

"And Exit the cout in D?? or I must import some library??" what do you mean?
You write to the standard output in D like this:

import std.stdio;

void main ()
{
	writefln("Hello D World"); // adds a new line
}

Again, look at the language specification 
http://www.digitalmars.com/d/1.0/lex.html and also the phobos (the 
standard library) link



More information about the Digitalmars-d mailing list