Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Tried it. It works.

Technically I look at methods as functions with a hidden first parameter that accepts a pointer to the class object's data. If you don't try to dereference that pointer, then the function should work like static member.

I was wondering if the compiler will add some check code preventing me from calling any method on a NULL pointed obj. But obviously its permitting it.

Of course virtual methods are different. Then you are calling a pointer to a function, the address of which should be stored in your obj data structure.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: