Friday, September 25, 2009

Vector - functions like methods

I would like to show different approach to providing methods to the users. Please note that it is only refactoring, functionality remains exactly the same.

So what it is all about? Simple.
Instead of doing this:
vector$getLength(my_v);
one can do that:
my_v->getLength(my_v);
Beside the fact that this is probably more convenient notation, methods will not interfere with those in different modules as user can access them only from object reference. Furthermore, user is able to replace any method with his own in particular object. While it is quite powerful it is not the case (I think) it would be wise to do so.



So let me jump right into.

auxilary.h
vector.h
vector.c
main.c

And examples of use:


No comments:

Post a Comment