Thread: Function behind the constructor

  1. #1
    Registered User
    Join Date
    Jan 2003
    Posts
    2

    Question Function behind the constructor

    SoundCardDevice::SoundCardDevice( const char* deviceName,
    Sptr < Fifo < Sptr<SipProxyEvent> > > inputQ,
    Sptr < Fifo < Sptr<SipProxyEvent> > > outputQ )
    : ResGwDevice( deviceName, inputQ, outputQ ),
    audioStack( 0 ),
    inRtpPkt( 0 ),
    ringbackFd( -1 )
    {

    function here...

    }


    I know this is a constructor, but what does it mean when functions:

    ResGwDevice( deviceName, inputQ, outputQ ),
    audioStack( 0 ),
    inRtpPkt( 0 ),
    ringbackFd( -1 )

    included at the end of it?

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    That's an initialization list, each of the members are initialized with the value in the parentheses:
    Code:
    class test {
      int a, b, c;
    public:
      test()
        : a(0), b(0), c(0)
      {}
    };
    The above constructor could also be written as:
    Code:
    test()
    {
      a = 0;
      b = 0;
      c = 0;
    }
    -Prelude
    My best code is written with the delete key.

  3. #3
    Registered User
    Join Date
    Dec 2002
    Posts
    103

    An added information

    int i = 10; //is initialize

    int i;
    i = 10; //is assignment.

    The first one in the previous post is initialization and second one is assignment. You would get into lot of situations in c++ where you would not be allowed to assign but only initialize.. for eg constants members

    PS: Please re-visit your previous post regarding
    "Sptr<CallId> myId meaning ", I have tried to explain it better
    Last edited by shiv_tech_quest; 01-09-2003 at 03:33 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Post your games here...
    By Hammer in forum Game Programming
    Replies: 132
    Last Post: 02-28-2013, 09:29 AM
  2. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 02:53 AM
  3. <Gulp>
    By kryptkat in forum Windows Programming
    Replies: 7
    Last Post: 01-14-2006, 01:03 PM
  4. Problem with Visual C++ Object-Oriented Programming Book.
    By GameGenie in forum C++ Programming
    Replies: 9
    Last Post: 08-29-2005, 11:21 PM
  5. Question..
    By pode in forum Windows Programming
    Replies: 12
    Last Post: 12-19-2004, 07:05 PM