Results 1 to 3 of 3

Thread: What's This?

  1. #1
    Join Date
    Jun 2011
    Posts
    203
    Thanks
    7
    Thanked 4 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default What's This?

    Hi Guys,

    Just bumped into something I've never seen before... here is the code:

    Qt Code:
    1. struct sockaddr_in peer
    To copy to clipboard, switch view to plain text mode 

    Why are there three elements? I've only ever seen anything instantiated by object/variable type e.g. int, struct, class etc and then the name of that instance of that variable i.e. in this case peer, what does sockaddr_in serve as in this example? An explanation or a web page with the explanation of this would be equally appreciated, I just don't even know what to search for.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: What's This?

    "struct sockaddr_in" is a structure type and "peer" is a name of the variable. The "struct" word comes from C and it is not needed in C++. In C you would also often see a typedef which maps "struct X" to "X" and then "X" would be used without the struct keyword.

    And if you ask about the structure itself then sockaddr_in is a structure for storing an address for an IP socket.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Jun 2011
    Posts
    203
    Thanks
    7
    Thanked 4 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: What's This?

    I think I see thanks.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.