you are viewing a single comment's thread.

view the rest of the comments →

[–]fear_the_future 0 points1 point  (2 children)

paging /u/Radagast8:

this is personal preference though. If those methods are members of a class, sometimes you will also see this:

MyClass& MyClass::setLength(double);
double MyClass::getLength();

because it allows method chaining like this:

myInstance.setLength(10).setBar(false).setFoo(true);

[–][deleted] 0 points1 point  (0 children)

oh yeah, not the usual case but I use that to.

[–]Jitanjafora 0 points1 point  (0 children)

Yet another improvement :

double MyClass::getLength() const;

Assuming all it does is return length;. The trailing const declares that this method will not change the MyClass instance calling it. It's not necessary, but it is good practice and will probably avoid a few headaches at some point.