Object pointers

Mar 30, 2012 at 3:59am
void function(A *objA); -> function call : function(*objA);

the function takes an object pointer. But when we call the function we pass the dereferenced pointer. Now passing the address is more efficient than passing the whole object copy. So tell me whether I have done it correct here.. thanks a lot for any valuable ideas on this.
Mar 30, 2012 at 4:03am
The function call would be function(&objA);, but if you're dealing with C++, don't abuse pointers - pass by reference instead.
Apr 5, 2012 at 4:38am
Okay Cubbi thanks for the comment. But what is the difference between C++ and C usage of pointers. As I know they look the same.

But since you have mentioned here specifically " but if you're dealing with C++, don't abuse pointers " it gives me a sense that I am wrong.

Please do tell me whats the difference.

And function (A* objA) is a function that takes an object pointer. So I see where I wrong, there is no need to pass the whole dereferenced object. Thanks Cubbi.
Topic archived. No new replies allowed.