C++ istream / ostream equivalent ?

Ali Çehreli acehreli at yahoo.com
Wed Dec 1 11:40:11 PST 2010


Matthias Pleh wrote:

 > class B{ string toString() {return "screen output routine here";}}

Isn't the 'override' keyword required? (Perhaps required only in D2?)

I find string.format very helpful in toString() member functions.

Finally, I still don't know whether the 'const'ness of the member 
function is required, allowed, or completely wrong. :)

import std.string;

class A
{
     override string toString() const
     {
         return format("My %s formatted string: %s", "lovely", 42);
     }
}

Ali


More information about the Digitalmars-d-learn mailing list