Friday, July 31, 2009

In strict sense parameters are passed by values only in C. For pass by reference we simulate it. IS this true

While passing by address, we pass the values of pointer variables i.e. addresses??





Also What is the difference between in call by reference and call by address in C. What abt C++??

In strict sense parameters are passed by values only in C. For pass by reference we simulate it. IS this true
You are correct..we pass the values of pointer variables...which in fact contain the address of where the real data is....so technically in C/C++ pointers are always 4-bytes in size despite the pointer type....it is when it is pointed to that you find the "real" type which can be things like char, int, byte, etc...





Call by Address and Call by Reference are synonymous with each other.





C++ has a newer feature over C where you can reference a variable as an "Alias" ... it's a much easier way than playing with pointers.
Reply:u r rite


dude





its the difference


in call by value value is copied to parameter


where as in reference address of the value is copied to parameter that can hold the value of address
Reply:I haven't programmed for a long time, but I remember you can pass by reference in C++. It's just a simple step that creates a substitute and has some very powerful advantages mainly when used with functions and in 'object oriented' programming. It's like giving a variable an 'alias'. It solves some problems that occur when passing by value.





I'm not sure if you can pass by reference in C (I don't think so).
Reply:Actually there is no call by reference concept in c,call by reference is in oops i think there is no diff in between call by ref in c++ and call by address in c


No comments:

Post a Comment