writeln an object

gedaiu szabobogdan at yahoo.com
Thu Apr 18 11:46:08 PDT 2013


On Thursday, 18 April 2013 at 18:25:21 UTC, John Colvin wrote:
> On Thursday, 18 April 2013 at 18:04:03 UTC, Andrej Mitrovic 
> wrote:
>> On 4/18/13, gedaiu <szabobogdan at yahoo.com> wrote:
>>> i've done that but i get this error:
>>>
>>> Error: function base.Value.Value.toString cannot override a
>>> non-virtual function
>>> Error: function base.Value.Value.toString override only 
>>> applies
>>> to class member functions
>>>
>>
>> If it's a struct then don't put "override".
>
> Just to provide a bit more info:
>
> Classes all derive from Object, which defines toString. Hence, 
> you need to override it to define your own.
>
> Structs don't have a parent (or any inheritance at all) and 
> hence you don't override anything, you just define the method.

i'm realy sorry... it's my mistake...

i have a struct not an object. I have someting like this when i 
get the error:

struct Value {
	string strVal;

         this(string val) {
		strVal = val;
	}

         override string toString() {
		return strVal;
	}
}


More information about the Digitalmars-d-learn mailing list