How to force a class to pass by reference like how java does
(using C++)??
Thanks
Printable View
How to force a class to pass by reference like how java does
(using C++)??
Thanks
This article should make it clear. Feel free to ask if still in doubt.
Hello jpn,
You didnt get me.
Let me explain...
-->in normal C++
Code:
class A { ..... }; void func( A &a ) //Is passed by reference { } int main() { A a; func( a ); return 0; }
-->What I want???
Code:
class A { ..... }; void func( A a ) //should be forced to pass by reference always. This happens in java { } int main() { A a; func( a ); return 0; }
As far as I know there is no other way around. "A &a" is how you do it in C++.
What do you mean?
You just pass the parameter by reference...