Results 1 to 2 of 2

Thread: Questions about the member of the structure.

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2003
    Posts
    74

    Questions about the member of the structure.

    The code below is a part of the select-server.cpp from the www.tangentsoft.net/wskfaq. I don't understand what is this line
    'Connection(SOCKET sd_) : sd(sd_), nCharsInBuffer(0) { }' in the Connection structure.


    struct Connection {
    SOCKET sd;
    char acBuffer[kBufferSize];
    int nCharsInBuffer;

    Connection(SOCKET sd_) : sd(sd_), nCharsInBuffer(0) { } // What is this?
    };
    typedef vector<Connection> ConnectionList;

    ConnectionList gConnections;
    Last edited by tommeal; Jun 13th, 2004 at 10:57 PM.

  2. #2
    Fanatic Member
    Join Date
    Dec 2003
    Posts
    703
    It's a constructor - a struct in c++ can have functions too. The constructor here is initialising the sd member with the parameter passed to it, and initialising the nCharsinBuffer member with zero.
    an ending

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width