What does this do?
float distancebetween( const Tacka& t );
float Tacka::rastojanje( const Tacka& t )
return ( sqrt( ( x-t.x)*(x-t.x) + ( y-t.y)*(y-t.y) ) );
pt = new Tacka;
cout << "tacke su na rastojanju " <<
t1.rastojanje( *pt ) << endl;
I am confused about const Tacka& t
is t object or pointer or adress of something?
Function in a class
Post a Reply
|Oldest Newest Rating|
· March 5, 2015
& in C++ means you are passing in the value by reference except you treat it as an object for simplicity. Anyway these two show functions are equivalent in that they do exactly the same thing except & uses slightly different sytnax. The only difference is that you don't need to dereference b/c & is just shorthand for using pointers.
void show(int* a)
void show(int& a)
Used in many types of software including music players, video games, and many large scale applications.
|Bucky Roberts Administrator|