Ah, thanks guys.
Type: Posts; User: thracian
Ah, thanks guys.
So with my example is the reference some random memory location or where the destroyed variable used to exist? If it's where it used to exist, why isn't func(x)=1?
There are instances in my book where the reference operator follows the return type and not the arguement type which is the source of this confusion.
#include <iostream>
using namespace std;
int& func(int a){ return a;}
int main(){
int x =1;
ahh, crap, i actually already understood the pass by reference idea, i just got it mixed up with the return type syntax. sorry about that.
let me ask a different question:
what type of variable...
what do you mean by reference? isn't a pointer a reference?
for example
int& func(int& a);
i keep seeing it in my book and it assumes you already know what it does, so it must be something basic. What does it do?
edit:
ohhh! cvector was also the return type, goddamnit, i completely missed that the first time.
int - return type
cvector- class
taxecab_distance - member function
thanks man
Ah, well I guess it makes sense now. Oh, and yeah, that's what I meant for the first part(b.x=1, and b.y=2), sorry for not making it clearer.
still trying to understand why cvector is repeated so...
When the constructor is called for the a and b objects:
CVector a (3,1);
CVector b (1,2);
a.x is assigned as 3 and a.y=1 as well as for b?
but then when this is called:
the b object comes after the operator, i don't understand what you mean....
in the case of the example, the operator+ is called implicitly with the + sign? i still don't understand what...
So then what is the arguement that is sent, or 'param'?
All right, so then what calls the overloaded function?
this code is frustrating me; it's an example from cplusplus.com(classes II)
i can't differentiate between which members are the constructors, why the overloading function is even called, and why...