sockaddr_in& what does the & mean?

The code is a declaration but I want to know what it means to put & right after the type.


 
  sockaddr_in& GetAddress();
It's declaring a reference return type (a reference to a sockaddr_in)

Reference (C++)
http://en.wikipedia.org/wiki/Reference_%28C%2B%2B%29

Andy

PS It doesn't have to be right after the type.

sockaddr_in &GetAddress();

sockaddr_in & GetAddress();

and even the pointlessly badly formatted

1
2
sockaddr_in                                         &			
                        GetAddress();


will all work.
Last edited on
Topic archived. No new replies allowed.