C++ reference type

Tom S h3r3tic at remove.mat.uni.torun.pl
Sat Jun 24 07:57:05 PDT 2006


David Medlock wrote:
> The attribute functions in classes serve this purpose do they not?
> 
> C++:
> int& my_attr();
> 
> D:
> void my_attr( int );
> 
> use, in both cases:
> foo.my_attr = 100;

Unless you want to be able to say 'foo.my_attr++;'
or 'foo.someStruct.bar = 1;'

The latter can be accomplished by making the function return a pointer 
to the struct, but then you cant say 'Foo x = my_attr();'


-- 
Tomasz Stachowiak  /+ a.k.a. h3r3tic +/



More information about the Digitalmars-d mailing list