C++ member function translations

Daniel919 Daniel919 at web.de
Fri Jul 27 05:57:20 PDT 2007


Classes are always passed by reference, so there is no need for &.
Structs are value types, they don't have a reference, so a ptr has to be 
used.

It's not possible to overload member functions by attribute.
So this is not possible:
class Foo {
     const void func() {/*don't change any fields*/}
     void func() {/*changes might happen*/}
}
Just like it's neither possible to overload by public / private.


 > C++:      const Foo& func(const Bar&) const;
const const(ClFoo) cfunc(const(StBar)*)
const const(StFoo)* cfunc(const(StBar)*)

 > C++:      const Foo& func(Bar&) const;
const const(ClFoo) cfunc(StBar*)
const const(StFoo)* cfunc(StBar*)

 > C++:      const Foo& func(const Bar&);
const(ClFoo) func(const(StBar)*)
const(StFoo)* func(const(StBar)*)

 > C++:      const Foo& func(Bar&);
const(ClFoo) func(StBar*)
const(StFoo)* func(StBar*)

 > C++:      Foo& func(Bar&) const;
const ClFoo cfunc(StBar*)
const StFoo* cfunc(StBar*)

 > C++:      Foo& func(Bar&);
ClFoo func(StBar*)
StFoo* func(StBar*)


Best regards,
Daniel


More information about the Digitalmars-d-learn mailing list